mirror of
https://github.com/luxfi/dex.git
synced 2026-09-24 00:26:31 +00:00
Default build pulls zero gRPC code; rebuild with `-tags=grpc` to opt
into gRPC.
Decomplected via a `grpcBackend` interface in `sdk/go/client` and a
`grpcSubClient` interface in `client/go`. The default build wires a
no-op backend (`*_nogrpc.go`); the `grpc` build wires the real
protobuf-backed client (`*_grpc.go`). Public methods stay the same in
both builds — the gRPC fast path is preferred when wired, else
JSON-RPC / WebSocket.
Files gated:
- pkg/grpc/pb/lxdex_grpc.pb.go (//go:build grpc)
- pkg/proto/engine/proto/lx_engine_grpc.pb.go (//go:build grpc)
Files refactored:
- sdk/go/client.go: //go:build grpc with stub in client_nogrpc.go
- sdk/go/client/client.go: gRPC removed from method bodies; backed by
the grpcBackend interface (grpc_backend{,_grpc,_nogrpc}.go)
- client/go/main.go: GrpcClient + ConnectGrpc moved to grpc.go
(//go:build grpc); nogrpc.go stubs ConnectGrpc with a clear error
Verification:
- go build ./... (default) clean across sdk/go, client/go, top-level
- go build -tags=grpc ./... clean across all three modules
- go test ./... and go test -tags=grpc ./... green
- go list -deps shows 0 google.golang.org/grpc packages in default
builds of sdk/go/client and client/go; 62 packages with -tags=grpc
READMEs in sdk/go and client/go document the build-tag opt-in.
36 lines
772 B
Go
36 lines
772 B
Go
//go:build grpc
|
|
|
|
package client
|
|
|
|
import "testing"
|
|
|
|
func TestTimeInForceConversion(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
tif TimeInForce
|
|
}{
|
|
{"GTC", TimeInForceGTC},
|
|
{"IOC", TimeInForceIOC},
|
|
{"FOK", TimeInForceFOK},
|
|
{"DAY", TimeInForceDAY},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
// Just ensure it doesn't panic
|
|
result := timeInForceToProto(tt.tif)
|
|
if result < 0 || result > 3 {
|
|
t.Errorf("timeInForceToProto(%s) returned invalid value %d", tt.tif, result)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestTimeInForceToProtoDefault(t *testing.T) {
|
|
// Unknown value should default to GTC (0)
|
|
result := timeInForceToProto(TimeInForce("UNKNOWN"))
|
|
if result != 0 {
|
|
t.Errorf("Expected default to be 0 (GTC), got %d", result)
|
|
}
|
|
}
|