From ff22ea71086aca717a81159ca477fed425689729 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Thu, 6 Jul 2023 11:23:57 +0800 Subject: [PATCH] chain unary interceptor --- cmd/api/main.go | 2 +- pkg/common/mw/rpc_client_interceptor.go | 2 +- pkg/common/mw/rpc_server_interceptor.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/api/main.go b/cmd/api/main.go index 6f56a7704..89235bd05 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -57,7 +57,7 @@ func run(port int) error { if err != nil { return err } - if client.CreateRpcRootNodes(config.GetServiceNames()); err != nil { + if err := client.CreateRpcRootNodes(config.GetServiceNames()); err != nil { return err } fmt.Println("api init discov client success") diff --git a/pkg/common/mw/rpc_client_interceptor.go b/pkg/common/mw/rpc_client_interceptor.go index e52366ec0..1f71bb532 100644 --- a/pkg/common/mw/rpc_client_interceptor.go +++ b/pkg/common/mw/rpc_client_interceptor.go @@ -16,7 +16,7 @@ import ( ) func GrpcClient() grpc.DialOption { - return grpc.WithUnaryInterceptor(RpcClientInterceptor) + return grpc.WithChainUnaryInterceptor(RpcClientInterceptor) } func RpcClientInterceptor(ctx context.Context, method string, req, resp interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err error) { diff --git a/pkg/common/mw/rpc_server_interceptor.go b/pkg/common/mw/rpc_server_interceptor.go index bd65042d5..45da3e2a8 100644 --- a/pkg/common/mw/rpc_server_interceptor.go +++ b/pkg/common/mw/rpc_server_interceptor.go @@ -153,5 +153,5 @@ func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary } func GrpcServer() grpc.ServerOption { - return grpc.UnaryInterceptor(RpcServerInterceptor) + return grpc.ChainUnaryInterceptor(RpcServerInterceptor) }