feat(gateway): export WithDialer option for custom gRPC client configuration (#5406)

This commit is contained in:
Kevin Wan
2026-02-06 21:50:50 +08:00
committed by GitHub
parent 9b74b7e09e
commit bdddf1f30c
2 changed files with 4 additions and 3 deletions

View File

@@ -329,8 +329,9 @@ func createDescriptorSource(cli zrpc.Client, up Upstream) (grpcurl.DescriptorSou
return source, nil return source, nil
} }
// withDialer sets a dialer to create a gRPC client. // WithDialer sets a dialer to create a gRPC client.
func withDialer(dialer func(conf zrpc.RpcClientConf) zrpc.Client) func(*Server) { // 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) { return func(s *Server) {
s.dialer = dialer s.dialer = dialer
} }

View File

@@ -54,7 +54,7 @@ func TestMustNewServer(t *testing.T) {
c.Host = "localhost" c.Host = "localhost"
c.Port = 18881 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()))) return zrpc.MustNewClient(conf, zrpc.WithDialOption(grpc.WithContextDialer(dialer())))
}), WithHeaderProcessor(func(header http.Header) []string { }), WithHeaderProcessor(func(header http.Header) []string {
return []string{"foo"} return []string{"foo"}