From 3de703eb83c589747e261a85989c2c9543f48eca Mon Sep 17 00:00:00 2001 From: "DESKTOP-V763RJ7\\Administrator" <835606593@qq.com> Date: Fri, 16 Jan 2026 23:50:14 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- net/grpc/service/service.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) 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) // 服务注册