caseyamcl / guzzle_retry_middleware

Middleware for Guzzle v6/7+ that automatically retries HTTP requests on 429, 503 responses.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[SUGGESTION] Callback for deciding retry timeout

mfn opened this issue · comments

The current implementation implements a hard-coded algorithm with a default_retry_multiplier.

This may be to inflexible if someone may want to use other means, like 2retryCount - 1 or similar.

As such it would be great if this could be a callback too, similar to what the \GuzzleHttp\RetryMiddleware::__construct(delay) does.

Yep, I plan on implementing this.

I didn't include it thus far, because my focus was on the Retry-After use-case. If you want to submit a PR and tests, feel free; otherwise I'll get it implemented as soon as I can.

Hi @mfn ... As of today's release (version 2.1), default_retry_multiplier now accepts a callable, per your suggestion.

You can read about how to use it here: https://github.com/caseyamcl/guzzle_retry_middleware#setting-default-retry-delay

Best regards!