Skip to content

Commit

Permalink
Do not use grpc.WithBlock option
Browse files Browse the repository at this point in the history
  • Loading branch information
karimra committed Jul 25, 2024
1 parent d443ac0 commit dd545b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion pkg/api/target/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func (t *Target) CreateGNMIClient(ctx context.Context, opts ...grpc.DialOption)
return err
}
opts = append(opts, tOpts...)
opts = append(opts, grpc.WithBlock())
// create a gRPC connection
addrs := strings.Split(t.Config.Address, ",")
numAddrs := len(addrs)
Expand Down
11 changes: 7 additions & 4 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,22 @@ func (a *App) PrintMsg(address string, msgName string, msg proto.Message) error
return nil
}

func (a *App) createCollectorDialOpts() []grpc.DialOption {
opts := []grpc.DialOption{grpc.WithBlock()}
func (a *App) createCollectorDialOpts() {
// append gRPC userAgent name
opts := []grpc.DialOption{grpc.WithUserAgent(fmt.Sprintf("gNMIc/%s", version))}
// add maxMsgSize
if a.Config.MaxMsgSize > 0 {
opts = append(opts, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(a.Config.MaxMsgSize)))
}
// Set NoProxy
if !a.Config.ProxyFromEnv {
opts = append(opts, grpc.WithNoProxy())
}
opts = append(opts, grpc.WithUserAgent(fmt.Sprintf("gNMIc/%s", version)))
// add gzip compressor
if a.Config.Gzip {
opts = append(opts, grpc.WithDefaultCallOptions(grpc.UseCompressor(gzip.Name)))
}
// enable metrics
if a.Config.APIServer != nil && a.Config.APIServer.EnableMetrics && a.reg != nil {
grpcClientMetrics := grpc_prometheus.NewClientMetrics()
opts = append(opts,
Expand All @@ -341,7 +345,6 @@ func (a *App) createCollectorDialOpts() []grpc.DialOption {
a.reg.MustRegister(grpcClientMetrics)
}
a.dialOpts = opts
return opts
}

func (a *App) watchConfig() {
Expand Down
3 changes: 2 additions & 1 deletion pkg/app/gnmi_client_subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ CRCLIENT:
case <-gnmiCtx.Done():
return gnmiCtx.Err()
default:
targetDialOpts := a.dialOpts
targetDialOpts := make([]grpc.DialOption, len(a.dialOpts))
copy(targetDialOpts, a.dialOpts)
if a.Config.UseTunnelServer {
a.ttm.Lock()
a.tunTargetCfn[tunnel.Target{ID: tc.Name, Type: tc.TunnelTargetType}] = cancel
Expand Down

0 comments on commit dd545b2

Please sign in to comment.