diff --git a/net/grpc/service/service.go b/net/grpc/service/service.go index 32d1871..416fedb 100644 --- a/net/grpc/service/service.go +++ b/net/grpc/service/service.go @@ -19,13 +19,14 @@ type IService interface { } type Base struct { - Target string - ServiceName string - SID string - Serve *grpc.Server - EtcdTTL int64 - OnInit func(serve *grpc.Server) - OnClose func() + Target string + ServiceName string + SID string + Serve *grpc.Server + EtcdTTL int64 + OnCustomGrpcServerOption func() []grpc.ServerOption + OnInit func(serve *grpc.Server) + OnClose func() wg *sync.WaitGroup } @@ -46,7 +47,7 @@ func (s *Base) Init(addr string, port int32) { return } - s.Serve = grpc.NewServer( + options := []grpc.ServerOption{ grpc.ChainUnaryInterceptor( s.RecoveryInterceptor, s.LoggingInterceptor, @@ -56,7 +57,9 @@ func (s *Base) Init(addr string, port int32) { MinTime: 20 * time.Second, PermitWithoutStream: true, }), - ) + } + options = append(options, s.OnCustomGrpcServerOption()...) + s.Serve = grpc.NewServer(options...) s.OnInit(s.Serve) // 服务注册