From 023e563de1f6242bad571fd69e83c9c1318320d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 12 Sep 2022 22:00:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4GRPC=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/api_node.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/nodes/api_node.go b/internal/nodes/api_node.go index a72c9bd9..07ff7b94 100644 --- a/internal/nodes/api_node.go +++ b/internal/nodes/api_node.go @@ -265,12 +265,18 @@ func (this *APINode) InstallSystemService() error { // 启动RPC监听 func (this *APINode) listenRPC(listener net.Listener, tlsConfig *tls.Config) error { var rpcServer *grpc.Server + var options = []grpc.ServerOption{ + grpc.MaxRecvMsgSize(128 * 1024 * 1024), + grpc.UnaryInterceptor(this.unaryInterceptor), + } + if tlsConfig == nil { remotelogs.Println("API_NODE", "listening GRPC http://"+listener.Addr().String()+" ...") - rpcServer = grpc.NewServer(grpc.MaxRecvMsgSize(128*1024*1024), grpc.UnaryInterceptor(this.unaryInterceptor)) + rpcServer = grpc.NewServer(options...) } else { logs.Println("[API_NODE]listening GRPC https://" + listener.Addr().String() + " ...") - rpcServer = grpc.NewServer(grpc.Creds(credentials.NewTLS(tlsConfig)), grpc.MaxRecvMsgSize(128*1024*1024), grpc.UnaryInterceptor(this.unaryInterceptor)) + options = append(options, grpc.Creds(credentials.NewTLS(tlsConfig))) + rpcServer = grpc.NewServer(options...) } this.registerServices(rpcServer) err := rpcServer.Serve(listener)