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
)
Feature Summary
Refactor the
RetryStrategyenum to unifyexponentialandexponentialWithJitterinto 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:
Proposed Solution
Consolidate the cases into one. The new
exponentialcase will include optionaljitterandmaxIntervalparameters with sensible defaults.