Skip to content

Expose *http.Response in the PrepareRetry function #252

@reecerussell

Description

@reecerussell

Hey all, we've been using retryablehttp for a lot of our internal and external API calls, making use of the backoff-retries, but we've run into a case where sometimes one of our providers times out consistently, when given specific requests. These types of requests typically involve a lot of work to be done by our provider, hence the timeouts, so we've tried to introduce some logic to identify these and update the request in-flight (so to speak).

It would be really useful to expand the PrepareRetry function to include the response of the last HTTP call too. With this we'd be able to understand why the request failed and to update the request respectively - in our case, we change a query parameter, which reduces the scope of the request and thus takes less time.

The way it stands currently is this: func(req *http.Request) error, but I'd like to change it to func(req *http.Request, resp *http.Response) error to allow inspecting the "failed" response.

Please let me know if anyone see's any issues or edge cases with this approach! Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions