Browse Source

v3rpc: change grpc max recv size as needed.

fanmin shi 8 years ago
parent
commit
68a72c6b6e
2 changed files with 4 additions and 3 deletions
  1. 4 1
      etcdserver/api/v3rpc/grpc.go
  2. 0 2
      integration/cluster.go

+ 4 - 1
etcdserver/api/v3rpc/grpc.go

@@ -24,6 +24,8 @@ import (
 	"google.golang.org/grpc/grpclog"
 	"google.golang.org/grpc/grpclog"
 )
 )
 
 
+const grpcOverheadBytes = 512 * 1024
+
 func init() {
 func init() {
 	grpclog.SetLogger(plog)
 	grpclog.SetLogger(plog)
 }
 }
@@ -36,8 +38,9 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config) *grpc.Server {
 	}
 	}
 	opts = append(opts, grpc.UnaryInterceptor(newUnaryInterceptor(s)))
 	opts = append(opts, grpc.UnaryInterceptor(newUnaryInterceptor(s)))
 	opts = append(opts, grpc.StreamInterceptor(newStreamInterceptor(s)))
 	opts = append(opts, grpc.StreamInterceptor(newStreamInterceptor(s)))
-
+	opts = append(opts, grpc.MaxMsgSize(int(s.Cfg.MaxRequestBytes+grpcOverheadBytes)))
 	grpcServer := grpc.NewServer(opts...)
 	grpcServer := grpc.NewServer(opts...)
+
 	pb.RegisterKVServer(grpcServer, NewQuotaKVServer(s))
 	pb.RegisterKVServer(grpcServer, NewQuotaKVServer(s))
 	pb.RegisterWatchServer(grpcServer, NewWatchServer(s))
 	pb.RegisterWatchServer(grpcServer, NewWatchServer(s))
 	pb.RegisterLeaseServer(grpcServer, NewQuotaLeaseServer(s))
 	pb.RegisterLeaseServer(grpcServer, NewQuotaLeaseServer(s))

+ 0 - 2
integration/cluster.go

@@ -61,8 +61,6 @@ const (
 	basePort     = 21000
 	basePort     = 21000
 	UrlScheme    = "unix"
 	UrlScheme    = "unix"
 	UrlSchemeTLS = "unixs"
 	UrlSchemeTLS = "unixs"
-
-	defaultMaxRequestSize
 )
 )
 
 
 var (
 var (