3
0

Add capability to set CORREDOR_MAX_RECEIVE_MESSAGE_SIZE, set default to 16MB

This commit is contained in:
Denis Arh 2020-03-04 14:19:41 +01:00
parent 7f0fcc72b9
commit 2aee9f80b9
2 changed files with 15 additions and 8 deletions

View File

@ -17,6 +17,8 @@ type (
MaxBackoffDelay time.Duration `env:"CORREDOR_MAX_BACKOFF_DELAY"`
MaxReceiveMessageSize int `env:"CORREDOR_MAX_RECEIVE_MESSAGE_SIZE"`
DefaultExecTimeout time.Duration `env:"CORREDOR_DEFAULT_EXEC_TIMEOUT"`
ListTimeout time.Duration `env:"CORREDOR_LIST_TIMEOUT"`
@ -36,14 +38,15 @@ type (
func Corredor() (o *CorredorOpt) {
o = &CorredorOpt{
Enabled: true,
RunAsEnabled: true,
Addr: "localhost:50051",
MaxBackoffDelay: time.Minute,
DefaultExecTimeout: time.Minute,
ListTimeout: time.Second * 2,
ListRefresh: time.Second * 5,
Log: false,
Enabled: true,
RunAsEnabled: true,
Addr: "localhost:50051",
MaxBackoffDelay: time.Minute,
MaxReceiveMessageSize: 2 << 23, // 16MB
DefaultExecTimeout: time.Minute,
ListTimeout: time.Second * 2,
ListRefresh: time.Second * 5,
Log: false,
TlsCertEnabled: true,
TlsCertPath: "/certs/corredor/client",

View File

@ -81,6 +81,10 @@ func NewConnection(ctx context.Context, opt options.CorredorOpt, logger *zap.Log
dialOpts = append(dialOpts, grpc.WithInsecure())
}
if opt.MaxReceiveMessageSize > 0 {
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(opt.MaxReceiveMessageSize))
}
if opt.MaxBackoffDelay > 0 {
dialOpts = append(dialOpts, grpc.WithBackoffMaxDelay(opt.MaxBackoffDelay))
}