Copyright | (c) Moritz Schulte 2017 |
---|---|
License | BSD3 |
Maintainer | mtesseract@silverratio.net |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
The async-refresh package provides the logic for periodic refreshing of arbitrary data. This module implements the core of the package and exposes its API.
- data AsyncRefreshConf m a
- data AsyncRefresh
- type AsyncRefreshCallback m a = Either SomeException (RefreshResult a) -> m ()
- data RefreshResult a = RefreshResult {
- refreshResult :: a
- refreshExpiry :: Maybe Int
- defaultAsyncRefreshInterval :: Int
- newAsyncRefreshConf :: MonadIO m => m (RefreshResult a) -> AsyncRefreshConf m a
- asyncRefreshConfSetDefaultInterval :: Int -> AsyncRefreshConf m a -> AsyncRefreshConf m a
- asyncRefreshConfSetLabel :: Text -> AsyncRefreshConf m a -> AsyncRefreshConf m a
- asyncRefreshConfSetFactor :: Double -> AsyncRefreshConf m a -> AsyncRefreshConf m a
- asyncRefreshConfSetCallback :: AsyncRefreshCallback m a -> AsyncRefreshConf m a -> AsyncRefreshConf m a
- newAsyncRefresh :: (MonadIO m, MonadBaseControl IO m, MonadCatch m, MonadMask m, MonadLogger m, Forall (Pure m)) => AsyncRefreshConf m a -> m AsyncRefresh
- asyncRefreshAsync :: AsyncRefresh -> Async ()
Documentation
data AsyncRefreshConf m a Source #
Data type defining an async refresh configuration.
data AsyncRefresh Source #
Data type denoting a running async refresher.
type AsyncRefreshCallback m a = Either SomeException (RefreshResult a) -> m () Source #
Type synonym for async refresh callbacks.
data RefreshResult a Source #
Data type returned by async refresh actions.
RefreshResult | |
|
Show a => Show (RefreshResult a) Source # | |
defaultAsyncRefreshInterval :: Int Source #
Default refresh interval is one minute (in milliseconds).
newAsyncRefreshConf :: MonadIO m => m (RefreshResult a) -> AsyncRefreshConf m a Source #
Given a refresh action, create a new configuration.
asyncRefreshConfSetDefaultInterval :: Int -> AsyncRefreshConf m a -> AsyncRefreshConf m a Source #
Set default refresh interval, specified in milliseconds, in the given configuration. If a refresh action fails or does not produce an expiry time, this interval will be used.
asyncRefreshConfSetLabel :: Text -> AsyncRefreshConf m a -> AsyncRefreshConf m a Source #
Set the label in the provided configuration. This is a human readable text, used for logging purposes.
asyncRefreshConfSetFactor :: Double -> AsyncRefreshConf m a -> AsyncRefreshConf m a Source #
Set the refresh factor. When a refresh gives an explicit expiry time after a succesful refresh run, then this expiry time will be multiplied by this factor, yielding the effective expiry time after which a new refresh run will be scheduled.
asyncRefreshConfSetCallback :: AsyncRefreshCallback m a -> AsyncRefreshConf m a -> AsyncRefreshConf m a Source #
Set a refresh callback for the provided configuration. This callback will be called after a refresh run.
newAsyncRefresh :: (MonadIO m, MonadBaseControl IO m, MonadCatch m, MonadMask m, MonadLogger m, Forall (Pure m)) => AsyncRefreshConf m a -> m AsyncRefresh Source #
Start a new thread taking care of refreshing of data according to the given configuration.
asyncRefreshAsync :: AsyncRefresh -> Async () Source #