| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Worker.BackoffStrategy
Description
Configurable backoff strategies for job retries.
Synopsis
- data BackoffStrategy
- data Jitter
- data ExponentialConfig = ExponentialConfig {}
- data LinearConfig = LinearConfig {}
- calculateBackoff :: BackoffStrategy -> Int32 -> NominalDiffTime
- applyJitter :: Jitter -> NominalDiffTime -> IO NominalDiffTime
- exponentialBackoff :: Double -> NominalDiffTime -> BackoffStrategy
- linearBackoff :: NominalDiffTime -> NominalDiffTime -> BackoffStrategy
- constantBackoff :: NominalDiffTime -> BackoffStrategy
Documentation
data BackoffStrategy Source #
Strategy for calculating retry delays based on attempt count.
Constructors
| Exponential ExponentialConfig | delay = base^attempts (e.g., 2s, 4s, 8s...) |
| Linear LinearConfig | delay = increment * attempts (e.g., 30s, 60s, 90s...) |
| Constant NominalDiffTime | Same delay for all attempts |
| Custom (Int32 -> NominalDiffTime) | User-provided function (attempts -> delay) |
Jitter strategy to randomize backoff delays.
Prevents thundering herd when many jobs fail simultaneously and retry at the same time.
Constructors
| NoJitter | Use exact calculated delay |
| FullJitter | delay = random(0, calculated_delay) |
| EqualJitter | delay = calculated_delay2 + random(0, calculated_delay2). Recommended. |
data ExponentialConfig Source #
Exponential backoff configuration.
Constructors
| ExponentialConfig | |
Fields | |
Instances
| Show ExponentialConfig Source # | |
Defined in Arbiter.Worker.BackoffStrategy Methods showsPrec :: Int -> ExponentialConfig -> ShowS # show :: ExponentialConfig -> String # showList :: [ExponentialConfig] -> ShowS # | |
| Eq ExponentialConfig Source # | |
Defined in Arbiter.Worker.BackoffStrategy Methods (==) :: ExponentialConfig -> ExponentialConfig -> Bool # (/=) :: ExponentialConfig -> ExponentialConfig -> Bool # | |
data LinearConfig Source #
Linear backoff configuration.
Constructors
| LinearConfig | |
Fields | |
Instances
| Show LinearConfig Source # | |
Defined in Arbiter.Worker.BackoffStrategy Methods showsPrec :: Int -> LinearConfig -> ShowS # show :: LinearConfig -> String # showList :: [LinearConfig] -> ShowS # | |
| Eq LinearConfig Source # | |
Defined in Arbiter.Worker.BackoffStrategy | |
calculateBackoff :: BackoffStrategy -> Int32 -> NominalDiffTime Source #
Calculate backoff delay for given attempt count (1-indexed).
applyJitter :: Jitter -> NominalDiffTime -> IO NominalDiffTime Source #
Apply jitter to a calculated delay.