@@ -48,12 +48,18 @@ import (
4848
4949var log = logger .New (logrus .StandardLogger (), "executorcmd" )
5050
51- func NewClient (controlPort uint64 , controlMode controlmode.ControlMode ) * RpcClient {
51+ type ControlTransport uint32
52+ const (
53+ ProtobufTransport = ControlTransport (0 )
54+ JsonTransport = ControlTransport (1 )
55+ )
56+
57+ func NewClient (controlPort uint64 , controlMode controlmode.ControlMode , controlTransport ControlTransport ) * RpcClient {
5258 endpoint := fmt .Sprintf ("127.0.0.1:%d" , controlPort )
5359 log .WithField ("endpoint" , endpoint ).Debug ("starting new gRPC client" )
5460
5561 cxt , cancel := context .WithTimeout (context .Background (), 20 * time .Second )
56- conn , err := grpc .DialContext (cxt , endpoint , grpc .WithInsecure ())
62+ conn , err := grpc .DialContext (cxt , endpoint , grpc .WithInsecure (), grpc . WithBlock () )
5763 if err != nil {
5864 log .WithField ("error" , err .Error ()).
5965 WithField ("endpoint" , endpoint ).
@@ -62,9 +68,15 @@ func NewClient(controlPort uint64, controlMode controlmode.ControlMode) *RpcClie
6268 return nil
6369 }
6470
71+ var occClient pb.OccClient
72+ if controlTransport == JsonTransport {
73+ occClient = nopb .NewOccClient (conn )
74+ } else {
75+ occClient = pb .NewOccClient (conn )
76+ }
77+
6578 client := & RpcClient {
66- //OccClient: pb.NewOccClient(conn),
67- OccClient : nopb .NewOccClient (conn ),
79+ OccClient : occClient ,
6880 conn : conn ,
6981 }
7082
0 commit comments