-
Notifications
You must be signed in to change notification settings - Fork 152
Description
Hello,
I would like to know if it is possible with the curent options set to support scenarios such as:
- retry a maximum of N times
- if the reponse is a closed error, retry and bump N to N+1 to not count the attempt
- if the response is a 429, retry a number of seconds based on a custom callback (the api I consume uses custom retry headers) and bump N+1 to not count the attempt
- otherwise count the attempt and retry with exponential backoff or custom duration callback
I am not sure this is possible for now. I think things could be simpler: By default, allow the :transient
, :safe_transient
and false
values for :retry
, and the :retry_delay
and :max_retries
options.
Otherwise, if :retry
is a function, disregard the :retry_delay
and :max_retries
completely. The function is given the request, the response/exception, and the remaining retries count. And it must return either {:noretry, response_or_exception}
or {:retry, delay_in_ms, remaining_retries_count}
.
I can even imagine disregarding :retry_log_level
as well and let the callback be responsible of logging.
That way, we would have more control over the retry mechanism as a whole and it would make the logic simpler.
Would you consider this change?
As a workaround, would you consider passing the response/exception to the retry_delay callback?
Thank you.