feat(inputs.gnmi): Set max gRPC message size (#12495)
This commit is contained in:
parent
eb03bb5599
commit
d3e1f95b87
|
|
@ -36,7 +36,10 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|||
# encoding = "proto"
|
||||
|
||||
## redial in case of failures after
|
||||
redial = "10s"
|
||||
# redial = "10s"
|
||||
|
||||
## gRPC Maximum Message Size
|
||||
# max_msg_size = "4MB"
|
||||
|
||||
## enable client-side TLS and define CA to authenticate the device
|
||||
# enable_tls = false
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ type GNMI struct {
|
|||
Subscriptions []Subscription `toml:"subscription"`
|
||||
TagSubscriptions []TagSubscription `toml:"tag_subscription"`
|
||||
Aliases map[string]string `toml:"aliases"`
|
||||
MaxMsgSize config.Size `toml:"max_msg_size"`
|
||||
|
||||
// Optional subscription configuration
|
||||
Encoding string
|
||||
|
|
@ -298,9 +299,17 @@ func (c *GNMI) subscribeGNMI(ctx context.Context, worker *Worker, tlscfg *tls.Co
|
|||
} else {
|
||||
creds = insecure.NewCredentials()
|
||||
}
|
||||
opt := grpc.WithTransportCredentials(creds)
|
||||
opts := []grpc.DialOption{
|
||||
grpc.WithTransportCredentials(creds),
|
||||
}
|
||||
|
||||
client, err := grpc.DialContext(ctx, worker.address, opt)
|
||||
if c.MaxMsgSize > 0 {
|
||||
opts = append(opts, grpc.WithDefaultCallOptions(
|
||||
grpc.MaxCallRecvMsgSize(int(c.MaxMsgSize)),
|
||||
))
|
||||
}
|
||||
|
||||
client, err := grpc.DialContext(ctx, worker.address, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to dial: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@
|
|||
# encoding = "proto"
|
||||
|
||||
## redial in case of failures after
|
||||
redial = "10s"
|
||||
# redial = "10s"
|
||||
|
||||
## gRPC Maximum Message Size
|
||||
# max_msg_size = "4MB"
|
||||
|
||||
## enable client-side TLS and define CA to authenticate the device
|
||||
# enable_tls = false
|
||||
|
|
@ -70,4 +73,4 @@
|
|||
# ## At least one path element name must be supplied that contains at least
|
||||
# ## one key to match on. Multiple element names can be specified in any
|
||||
# ## order. In this case all element names must be present.
|
||||
# elements = ["description", "interface"]
|
||||
# elements = ["description", "interface"]
|
||||
|
|
|
|||
Loading…
Reference in New Issue