Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- retry :: (MonadCatch m, MonadIO m) => RetrySettings -> (RetryStatus -> m a) -> m a
- retryFor :: (Exception exc, MonadIO m, MonadCatch m) => RetrySettings -> (exc -> m RetryAction) -> (RetryStatus -> m a) -> m a
- data RetrySettings = RetrySettings {}
- defaults :: RetrySettings
- data RetryAction
- data RetryStatus = RetryStatus {}
- escalateWith :: Exception exc => (err -> exc) -> Either err a -> IO a
- escalate :: Exception exc => Either exc a -> IO a
- withLeft :: a -> Maybe b -> Either a b
Documentation
retry :: (MonadCatch m, MonadIO m) => RetrySettings -> (RetryStatus -> m a) -> m a Source #
Retry on all sync exceptions, async exceptions will still be thrown.
The backoff delays between retries grow exponentially plus a random jitter. The backoff for retry attempt number _attempt_ is computed as:
backoffExpBase ** (attempt - 1) + random(0, backoffJitter)
With the default values, the backoff for the first 5 attempts will be:
2 ** 0 + random(0, 1) = 1 + random(0, 1) 2 ** 1 + random(0, 1) = 2 + random(0, 1) 2 ** 2 + random(0, 1) = 4 + random(0, 1) 2 ** 3 + random(0, 1) = 8 + random(0, 1) 2 ** 4 + random(0, 1) = 16 + random(0, 1)
If all retries fail, the last exception is let through.
retryFor :: (Exception exc, MonadIO m, MonadCatch m) => RetrySettings -> (exc -> m RetryAction) -> (RetryStatus -> m a) -> m a Source #
data RetrySettings Source #
Settings for the retry functions.
RetrySettings | |
|
data RetryAction Source #
Instances
Show RetryAction Source # | |
Defined in Stamina showsPrec :: Int -> RetryAction -> ShowS # show :: RetryAction -> String # showList :: [RetryAction] -> ShowS # | |
Eq RetryAction Source # | |
Defined in Stamina (==) :: RetryAction -> RetryAction -> Bool # (/=) :: RetryAction -> RetryAction -> Bool # |
data RetryStatus Source #
Tracks the status of a retry
All fields will be zero if no retries have been attempted yet.
RetryStatus | |
|