async-refresh- Package implementing core logic for refreshing of expiring data.

Copyright(c) Moritz Clasmeier 2017-2018
Safe HaskellNone



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 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.




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 :: (MonadUnliftIO m, MonadCatch m, MonadMask m, MonadLogger m) => AsyncRefreshConf m a -> m AsyncRefresh Source #

Start a new thread taking care of refreshing of data according to the given configuration.