amitfin / retry

Home Assistant Integration with Retry Service
MIT License
104 stars 4 forks source link

Feature request - backoff multiplier #101

Closed janchrillesen closed 3 months ago

janchrillesen commented 3 months ago

Checklist

Is your feature request related to a problem? Please describe.

I would like to use the integration for a service that takes some time to come up when it fails - in this case waking up my EV from sleep. The backoff intervals are very agressive for this use case

Describe the solution you'd like

I would like to propose a back-off multiplier

For instance setting backoff multiplier to 5, would change the intervals from

0, 1, 2, 4, 8, 16, 32 seconds

to

0, 5, 10, 20, 40, 80, 160 seconds

Describe alternatives you've considered

Using a high number of retries, but this initiates unneeded calls to the EV

Additional context

None

amitfin commented 3 months ago

image

Can you try increasing the retries parameter (default is 7)? If it doesn't help, please elaborate on the problem.

janchrillesen commented 3 months ago

The problem is that I am calling a webservice, with a daily API rate limit, and it might take 30 seconds to be ready. With the default backoff I will end up sending 6 requests before the service is ready, while with the multiplier I will only send 4 calls. For this exact scenario a linear solution would be even better - for instance retry every 20 seconds, for a max of 5 attempts - but I assumed a multiplier would be easier to implement

amitfin commented 3 months ago

v2.11.0 adds a new backoff parameter to allow customization. Documentation can be found here.

@janchrillesen , please let me know if it's working and addressing your needs.

janchrillesen commented 3 months ago

Thank you very much. Just to make sure that I understand the documentation correct - for a linear backoff the square brackets should not be used? The documentation says "10" and not "[[ 10 ]]", while the other examples does include square brackets

amitfin commented 3 months ago

Correct. When the delay is constant there is no need to wrap it with a template expression. A simple string is enough.