mirror of
https://github.com/cachix/stamina.hs.git
synced 2024-09-11 18:37:48 +03:00
1.9 KiB
1.9 KiB
Stamina
A retry Haskell library for humans:
- Exponential backoff with jitter between retries.
- Limit the attempts of retries and total time.
Stamina.HTTP
for retrying retriableNetwork.HTTP.Client
exceptions.- Introspectable retry state for logging using
RetryStatus
, including the exception that occured. - Support resetting the retry state when the action is long-running and an attempt works.
API
RetryAction
RetryStatus
defaults
retry
retryOnExceptions
Example
import qualified Stamina
import Control.Monad.Catch (throwM)
go :: IO ()
go = do
defaults <- Stamina.defaults
Stamina.retry defaults $ \retryStatus -> do
throwM $ userError "nope"
Example to catch specific exceptions
isDoesNotExistError :: IOError -> Stamina.RetryAction
isDoesNotExistError _ = return Stamina.Retry
go2 :: IO ()
go2 = do
defaults <- Stamina.defaults
Stamina.retryOnExceptions defaults isDoesNotExistError $ \retryStatus -> do
throwM $ userError "nope"
Development
-
Install devenv.sh.
-
devenv shell
-
stack build
Credits
- Heavily inspired by stamina for Python.
- retry as case study for what needs to be supported.
Test setup
main = undefined