From 45ded2d3754573132dc9714bcfa50d9de6c6f5f1 Mon Sep 17 00:00:00 2001 From: David Liu Date: Thu, 4 Jan 2024 11:18:53 +0800 Subject: [PATCH] feat: make server options configurable --- plugins/grpc/grpc.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/grpc/grpc.go b/plugins/grpc/grpc.go index 993da8c..b951740 100644 --- a/plugins/grpc/grpc.go +++ b/plugins/grpc/grpc.go @@ -27,6 +27,12 @@ type GrpcServer struct { listener *net.Listener } +var globalServerOptions []grpc.ServerOption + +func SetGlobalServerOptions(options ...grpc.ServerOption) { + globalServerOptions = options +} + func (g GrpcServer) Server() *grpc.Server { return g.server } @@ -63,6 +69,7 @@ func (g *GrpcServer) Shutdown() { } func (g *GrpcServer) Configure(opt ...grpc.ServerOption) { + opt = append(globalServerOptions, opt...) grpc := grpc.NewServer(opt...) reflection.Register(grpc) g.server = grpc