chain unary interceptor

pull/476/head
withchao 2 years ago
parent 28fad04d5c
commit ff22ea7108

@ -57,7 +57,7 @@ func run(port int) error {
if err != nil { if err != nil {
return err return err
} }
if client.CreateRpcRootNodes(config.GetServiceNames()); err != nil { if err := client.CreateRpcRootNodes(config.GetServiceNames()); err != nil {
return err return err
} }
fmt.Println("api init discov client success") fmt.Println("api init discov client success")

@ -16,7 +16,7 @@ import (
) )
func GrpcClient() grpc.DialOption { 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) { func RpcClientInterceptor(ctx context.Context, method string, req, resp interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err error) {

@ -153,5 +153,5 @@ func RpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
} }
func GrpcServer() grpc.ServerOption { func GrpcServer() grpc.ServerOption {
return grpc.UnaryInterceptor(RpcServerInterceptor) return grpc.ChainUnaryInterceptor(RpcServerInterceptor)
} }

Loading…
Cancel
Save