wrap before the call, we don't want to rewrap on retry

This commit is contained in:
Asim 2016-11-09 18:02:41 +00:00
parent c277a3ecc0
commit 99a3ba7358

View File

@ -250,6 +250,14 @@ func (r *rpcClient) Call(ctx context.Context, request Request, response interfac
default: 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) // return errors.New("go.micro.client", "request timeout", 408)
call := func(i int) error { call := func(i int) error {
// call backoff first. Someone may want an initial start delay // 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) 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 // make the call
err = rcall(ctx, address, request, response, callOpts) err = rcall(ctx, address, request, response, callOpts)
r.opts.Selector.Mark(request.Service(), node, err) r.opts.Selector.Mark(request.Service(), node, err)