From 99a3ba7358933604f107a96d02ceff2a979c6de7 Mon Sep 17 00:00:00 2001 From: Asim Date: Wed, 9 Nov 2016 18:02:41 +0000 Subject: [PATCH] wrap before the call, we don't want to rewrap on retry --- client/rpc_client.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/client/rpc_client.go b/client/rpc_client.go index ee40728f..ed38a722 100644 --- a/client/rpc_client.go +++ b/client/rpc_client.go @@ -250,6 +250,14 @@ func (r *rpcClient) Call(ctx context.Context, request Request, response interfac default: } + // make copy of call method + rcall := r.call + + // wrap the call in reverse + for i := len(callOpts.CallWrappers); i > 0; i-- { + rcall = callOpts.CallWrappers[i-1](rcall) + } + // return errors.New("go.micro.client", "request timeout", 408) call := func(i int) error { // call backoff first. Someone may want an initial start delay @@ -277,12 +285,6 @@ func (r *rpcClient) Call(ctx context.Context, request Request, response interfac address = fmt.Sprintf("%s:%d", address, node.Port) } - // wrap the call in reverse - rcall := r.call - for i := len(callOpts.CallWrappers); i > 0; i-- { - rcall = callOpts.CallWrappers[i-1](rcall) - } - // make the call err = rcall(ctx, address, request, response, callOpts) r.opts.Selector.Mark(request.Service(), node, err)