From d31f82070509c4aeb26a5ebac4bcd207d49cb242 Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Thu, 30 Jul 2020 15:22:36 +0100 Subject: [PATCH] client: add proxy option (#1885) * client: add proxy option * client: add WithProxy CallOption * use address option * ProxyAddress => Proxy --- grpc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/grpc.go b/grpc.go index 2ed71bd..4ee1738 100644 --- a/grpc.go +++ b/grpc.go @@ -411,6 +411,11 @@ func (g *grpcClient) Call(ctx context.Context, req client.Request, rsp interface callOpts.Selector = g.opts.Selector } + // inject proxy address + if len(callOpts.Address) == 0 && len(g.opts.Proxy) > 0 { + callOpts.Address = []string{g.opts.Proxy} + } + // lookup the route to send the reques to route, err := client.LookupRoute(req, callOpts) if err != nil { @@ -514,6 +519,11 @@ func (g *grpcClient) Stream(ctx context.Context, req client.Request, opts ...cli callOpts.Selector = g.opts.Selector } + // inject proxy address + if len(callOpts.Address) == 0 && len(g.opts.Proxy) > 0 { + callOpts.Address = []string{g.opts.Proxy} + } + // lookup the route to send the reques to route, err := client.LookupRoute(req, callOpts) if err != nil {