mirror of
https://github.com/cachix/stamina.hs.git
synced 2024-09-11 18:37:48 +03:00
more docs
This commit is contained in:
parent
b9c3b23cef
commit
5d52cc1339
24
README.md
24
README.md
@ -1,21 +1,15 @@
|
||||
# Stamina.hs
|
||||
|
||||
**WIP: doesn't work yet, in design phase.**
|
||||
**WIP: doesn't work yet, in a design phase.**
|
||||
|
||||
[![Hackage](https://img.shields.io/hackage/v/stamina.svg?style=flat)](https://hackage.haskell.org/package/stamina) ![CI status](https://github.com/cachix/stamina.hs/actions/workflows/ci.yml/badge.svg)
|
||||
|
||||
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.
|
||||
- **Exponential backoff** with **jitter** between retries.
|
||||
- Limit the **attempts** of retries and **total** time.
|
||||
- `Stamina.HTTP` for retrying retriable `Network.HTTP.Client` exceptions.
|
||||
- Introspectable retry state for logging using `RetryStatus`.
|
||||
|
||||
## API
|
||||
|
||||
@ -23,6 +17,12 @@ A retry Haskell library for humans:
|
||||
|
||||
defaultRetrySettings :: RetrySettings
|
||||
|
||||
data RetryStatus = RetryStatus
|
||||
{ attempts :: Int,
|
||||
delay :: Int,
|
||||
totalDelay :: Int
|
||||
}
|
||||
|
||||
-- Retry on all sync exceptions
|
||||
retry :: MonadIO m => RetrySettings -> (RetryStatus -> m a) -> m a
|
||||
|
||||
@ -40,7 +40,7 @@ import qualified Stamina
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
Stamina.retry Stamina.defaultRetrySettings $ \retryStatus -> do
|
||||
Stamina.retry Stamina.defaults $ \retryStatus -> do
|
||||
... monadic logic that raises exceptions
|
||||
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user