From bdddf1f30cee59d6336727cfbefd0620c38ae9b3 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Fri, 6 Feb 2026 21:50:50 +0800 Subject: [PATCH] feat(gateway): export WithDialer option for custom gRPC client configuration (#5406) --- gateway/server.go | 5 +++-- gateway/server_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gateway/server.go b/gateway/server.go index 4a5578ff4..a111f6c72 100644 --- a/gateway/server.go +++ b/gateway/server.go @@ -329,8 +329,9 @@ func createDescriptorSource(cli zrpc.Client, up Upstream) (grpcurl.DescriptorSou return source, nil } -// withDialer sets a dialer to create a gRPC client. -func withDialer(dialer func(conf zrpc.RpcClientConf) zrpc.Client) func(*Server) { +// WithDialer sets a dialer to create a gRPC client. +// This allows customization of gRPC client options, such as message size limits. +func WithDialer(dialer func(conf zrpc.RpcClientConf) zrpc.Client) func(*Server) { return func(s *Server) { s.dialer = dialer } diff --git a/gateway/server_test.go b/gateway/server_test.go index 7eff9eb47..dfb794658 100644 --- a/gateway/server_test.go +++ b/gateway/server_test.go @@ -54,7 +54,7 @@ func TestMustNewServer(t *testing.T) { c.Host = "localhost" c.Port = 18881 - s := MustNewServer(c, withDialer(func(conf zrpc.RpcClientConf) zrpc.Client { + s := MustNewServer(c, WithDialer(func(conf zrpc.RpcClientConf) zrpc.Client { return zrpc.MustNewClient(conf, zrpc.WithDialOption(grpc.WithContextDialer(dialer()))) }), WithHeaderProcessor(func(header http.Header) []string { return []string{"foo"}