Ignore zero max message size in grpc config

Fixes upgrade issue where existing configs cause
the max message size to get set to 0.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan 2018-06-01 16:21:53 -07:00
parent 5b1f69be8a
commit 993d4b8fc5
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -66,12 +66,18 @@ func New(ctx context.Context, config *Config) (*Server, error) {
if err != nil {
return nil, err
}
rpc := grpc.NewServer(
grpc.MaxRecvMsgSize(config.GRPC.MaxRecvMsgSize),
grpc.MaxSendMsgSize(config.GRPC.MaxSendMsgSize),
serverOpts := []grpc.ServerOption{
grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor),
grpc.StreamInterceptor(grpc_prometheus.StreamServerInterceptor),
)
}
if config.GRPC.MaxRecvMsgSize > 0 {
serverOpts = append(serverOpts, grpc.MaxRecvMsgSize(config.GRPC.MaxRecvMsgSize))
}
if config.GRPC.MaxSendMsgSize > 0 {
serverOpts = append(serverOpts, grpc.MaxSendMsgSize(config.GRPC.MaxSendMsgSize))
}
rpc := grpc.NewServer(serverOpts...)
var (
services []plugin.Service
s = &Server{