Skip to content

[FEATURE] Union exponential and exponentialWithJitter strategies #57

@ns-vasilev

Description

@ns-vasilev

Feature Summary

Refactor the RetryStrategy enum to unify exponential and exponentialWithJitter into a single, more flexible exponential case. This will be achieved by making jitter and maximum interval optional parameters.

Motivation

Currently, exponential and exponentialWithJitter exist as separate cases. This leads to:

  • Redundancy: Both cases share similar parameters (retry, multiplier, duration).
  • Rigidity: If a user wants to use a basic exponential backoff but add a maxInterval, they are forced to use the exponentialWithJitter case even if they don't want jitter.
  • API Bloat: Having two distinct cases for essentially the same mathematical progression makes the library harder to navigate.

Proposed Solution

Consolidate the cases into one. The new exponential case will include optional jitter and maxInterval parameters with sensible defaults.

case exponential(
    retry: Int,
    multiplier: Double = 2.0,
    duration: DispatchTimeInterval,
    jitter: Double? = nil,
    maxInterval: DispatchTimeInterval? = nil
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions