stamina.hs/README.md
2023-07-05 15:14:19 +01:00

1.4 KiB

Stamina.hs

WIP: doesn't work yet, in design phase.

Hackage CI status

A retry Haskell library for humans:

  • Exponential backoff with jitter between retries.
  • Limit the number of retries and total time.
  • Stamina.HTTP for retrying retriable HTTP Exceptions
  • Introspectable retry state for logging

Design goals

  • Defaults that make sense most of the time.
  • Simple interface.
  • Documented.

API


defaultRetrySettings :: RetrySettings

-- Retry on all sync exceptions
retry :: MonadIO m => RetrySettings -> (RetryStatus -> m a) -> m a

-- Retry on specific exceptions
retryOnExceptions :: (Exception e, MonadIO m) => RetrySettings -> [Handler RetryAction] -> (RetryStatus -> m a) -> m a

data RetryAction = Skip | Retry | RetryAfter Int

Example


import qualified Stamina

main :: IO ()
main = do
    Stamina.retry Stamina.defaultRetrySettings $ \retryStatus -> do
        ... monadic logic that raises exceptions

Development

  1. Install devenv.sh.

  2. devenv shell

  3. stack build

Credits