resty icon indicating copy to clipboard operation
resty copied to clipboard

Add WrapExecutor

Open lavoiesl opened this issue 4 years ago • 4 comments

Add the ability to wrap the request executor, granting full access to the request, response, and error. Runs on every request attempt, before any request hook and after any response or error hook.

Can be useful to introduce throttling or add hooks that always fire, regardless of success or error. Having access to the request even in case of errors means also having access to the request's context, which can be immensely helpful for proper error logging/reporting.

This PR is dependant on https://github.com/go-resty/resty/pull/478, to avoid re-wrapping noRetryError

lavoiesl avatar Oct 14 '21 18:10 lavoiesl

@lavoiesl Thanks for your suggestion. With this improvement, I think we can restructure within Resty. I will consider this for Resty v3

jeevatkm avatar Oct 24 '21 23:10 jeevatkm

@jeevatkm Is there still a plan to release a v3? We ended up having to maintain a fork of resty because this hook proved essential to throttling, error handling, and metrics gathering.

lavoiesl avatar Jan 19 '23 19:01 lavoiesl

@lavoiesl I will aim this concept for v3. I know, I got delayed so much, I will make up for it. Thanks for your patience.

jeevatkm avatar Mar 05 '23 23:03 jeevatkm