Prechádzať zdrojové kódy

v3rpc: Let clients establish unlimited streams

From go-grpc v1.2.0, the number of max streams per client is set to 100
by default by the server side. This change makes it impossible
for third party proxies and custom clients to establish many streams.
Iwasaki Yudai 8 rokov pred
rodič
commit
536a5f594b
1 zmenil súbory, kde vykonal 5 pridanie a 1 odobranie
  1. 5 1
      etcdserver/api/v3rpc/grpc.go

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

@@ -16,6 +16,7 @@ package v3rpc
 
 import (
 	"crypto/tls"
+	"math"
 
 	"github.com/coreos/etcd/etcdserver"
 	pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
@@ -24,6 +25,8 @@ import (
 	"google.golang.org/grpc/grpclog"
 )
 
+const maxStreams = math.MaxUint32
+
 func init() {
 	grpclog.SetLogger(plog)
 }
@@ -36,8 +39,9 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config) *grpc.Server {
 	}
 	opts = append(opts, grpc.UnaryInterceptor(newUnaryInterceptor(s)))
 	opts = append(opts, grpc.StreamInterceptor(newStreamInterceptor(s)))
-
+	opts = append(opts, grpc.MaxConcurrentStreams(maxStreams))
 	grpcServer := grpc.NewServer(opts...)
+
 	pb.RegisterKVServer(grpcServer, NewQuotaKVServer(s))
 	pb.RegisterWatchServer(grpcServer, NewWatchServer(s))
 	pb.RegisterLeaseServer(grpcServer, NewQuotaLeaseServer(s))