Skip to content

Allow setting both total duration and max retries #23

@agasparovic

Description

@agasparovic

Motivations

When creating an ExponentialBackoff policy, I'd like to be able to specify two things:

  • That I'll try at most 3 times,
  • That I'll try for at most 60 seconds, whether or not I am able to complete 3 retries within the 60 seconds.

Solution

ExponentialBackoffBuilder would have a build_with_max_retries_and_total_duration method

or

ExponentialBackoffTimed::backoff would be public so that I could set ExponentialBackoff::max_n_retries (which is already public)

or

ExponentialBackoffBuilder would have a max_n_retries method that could be used to set it before calling build_with_total_duration.

Alternatives

I had assumed that build_with_total_retry_duration_and_max_retries would already accept a duration and number of retries, until I looked closer and saw that it calculates the number of retries that could fit within the duration. But what I'd like is a way to specify what's described in the doc comment: "...enforce whatever comes first, max retries or total duration."

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions