gojek / heimdall

An enhanced HTTP client for Go
http://gojek.tech
Apache License 2.0
2.63k stars 214 forks source link

Handle request cancellation properly #91

Closed vthiery closed 2 years ago

vthiery commented 4 years ago

When a request is being cancelled by the caller via the context, even though the underlying HTTP client should not perform any more request and directly return, the backoff mechanism still kicks in and leaves the caller waiting for multiple backoff periods for nothing.

I had a look at #17 and #28 and thought that maybe this solution, that does not change the signatures and fully uses the context that callers set on the HTTP request might work.

coveralls commented 4 years ago

Coverage Status

Coverage decreased (-8.8%) to 91.247% when pulling f123478c319468f1f8d19c1a2096d5f76cb8e53d on vthiery:improve-req-cancellation into 2f1fd2700e9d549092e9c249e08be101a6a887c6 on gojek:master.