client: add proxy option (#1885)

* client: add proxy option

* client: add WithProxy CallOption

* use address option

* ProxyAddress => Proxy
This commit is contained in:
ben-toogood 2020-07-30 15:22:36 +01:00 committed by Vasiliy Tolstov
parent 046db9e178
commit d31f820705

10
grpc.go
View File

@ -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 {