Merge pull request #17922 from marefr/chore_grpc_chain_interceptors

Chore: Use chain interceptors from grpc package
This commit is contained in:
Benjamin Wang 2024-05-03 06:48:01 +01:00 committed by GitHub
commit 3096df2207
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 10 deletions

View File

@ -29,7 +29,6 @@ import (
"path/filepath"
"time"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_zap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap"
grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
@ -481,12 +480,8 @@ func newGRPCProxyServer(lg *zap.Logger, client *clientv3.Client) *grpc.Server {
}
gopts := []grpc.ServerOption{
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
grpcChainStreamList...,
)),
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
grpcChainUnaryList...,
)),
grpc.ChainStreamInterceptor(grpcChainStreamList...),
grpc.ChainUnaryInterceptor(grpcChainUnaryList...),
grpc.MaxConcurrentStreams(math.MaxUint32),
}
if grpcKeepAliveMinTime > time.Duration(0) {

View File

@ -18,7 +18,6 @@ import (
"crypto/tls"
"math"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
@ -61,8 +60,8 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config, interceptor grpc.UnarySer
}
opts = append(opts, grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(chainUnaryInterceptors...)))
opts = append(opts, grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(chainStreamInterceptors...)))
opts = append(opts, grpc.ChainUnaryInterceptor(chainUnaryInterceptors...))
opts = append(opts, grpc.ChainStreamInterceptor(chainStreamInterceptors...))
opts = append(opts, grpc.MaxRecvMsgSize(int(s.Cfg.MaxRequestBytes+grpcOverheadBytes)))
opts = append(opts, grpc.MaxSendMsgSize(maxSendBytes))