Skip to content

Commit

Permalink
Add option to configure max received message size for remote grpc sto…
Browse files Browse the repository at this point in the history
…rage plugin
  • Loading branch information
SOF3 committed May 9, 2023
1 parent 5c3c20d commit 6896a5b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugin/storage/grpc/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Configuration struct {
RemoteTLS tlscfg.Options
RemoteConnectTimeout time.Duration `yaml:"connection-timeout" mapstructure:"connection-timeout"`
TenancyOpts tenancy.Options
MaxRecvMsgSize int `yaml:"max-receive-message-size" mapstructure:"max-receive-message-size"`

pluginHealthCheck *time.Ticker
pluginHealthCheckDone chan bool
Expand Down Expand Up @@ -84,6 +85,7 @@ func (c *Configuration) Close() error {

func (c *Configuration) buildRemote(logger *zap.Logger) (*ClientPluginServices, error) {
opts := []grpc.DialOption{
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(c.MaxRecvMsgSize)),
grpc.WithUnaryInterceptor(otgrpc.OpenTracingClientInterceptor(opentracing.GlobalTracer())),
grpc.WithStreamInterceptor(otgrpc.OpenTracingStreamClientInterceptor(opentracing.GlobalTracer())),
grpc.WithBlock(),
Expand Down
3 changes: 3 additions & 0 deletions plugin/storage/grpc/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
remotePrefix = "grpc-storage"
remoteServer = remotePrefix + ".server"
remoteConnectionTimeout = remotePrefix + ".connection-timeout"
grpcMaxRecvMsgSize = remotePrefix + ".max-recv-msg-size"
defaultPluginLogLevel = "warn"
defaultConnectionTimeout = time.Duration(5 * time.Second)
)
Expand All @@ -58,6 +59,7 @@ func (opt *Options) AddFlags(flagSet *flag.FlagSet) {
flagSet.String(pluginLogLevel, defaultPluginLogLevel, "Set the log level of the plugin's logger")
flagSet.String(remoteServer, "", "The remote storage gRPC server address as host:port")
flagSet.Duration(remoteConnectionTimeout, defaultConnectionTimeout, "The remote storage gRPC server connection timeout")
flagSet.Int(grpcMaxRecvMsgSize, 4<<20, "The maximum receivable message size to receive from the remote storage gRPC server")
}

// InitFromViper initializes Options with properties from viper
Expand All @@ -73,5 +75,6 @@ func (opt *Options) InitFromViper(v *viper.Viper) error {
}
opt.Configuration.RemoteConnectTimeout = v.GetDuration(remoteConnectionTimeout)
opt.Configuration.TenancyOpts = tenancy.InitFromViper(v)
opt.Configuration.MaxRecvMsgSize = v.GetInt(grpcMaxRecvMsgSize)
return nil
}

0 comments on commit 6896a5b

Please sign in to comment.