grpc interceptor

This commit is contained in:
wangchuxiao
2023-05-09 11:24:58 +08:00
parent d18c7e2c52
commit f5c80ffd50
4 changed files with 33 additions and 5 deletions
+2 -3
View File
@@ -28,7 +28,6 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
return err
}
defer listener.Close()
fmt.Println(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema, rpcRegisterName)
zkClient, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.UserName,
config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10))
@@ -46,10 +45,10 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
prome.NewGrpcRequestCounter()
prome.NewGrpcRequestFailedCounter()
prome.NewGrpcRequestSuccessCounter()
unaryInterceptor := mw.InterceptChain(grpcPrometheus.UnaryServerInterceptor, grpcPrometheus.UnaryServerInterceptor)
options = append(options, []grpc.ServerOption{
//grpc.UnaryInterceptor(prome.UnaryServerInterceptorPrometheus),
grpc.StreamInterceptor(grpcPrometheus.StreamServerInterceptor),
grpc.UnaryInterceptor(grpcPrometheus.UnaryServerInterceptor),
grpc.UnaryInterceptor(unaryInterceptor),
}...)
}
srv := grpc.NewServer(options...)