The async-refresh package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

This package can be used for refreshing of expiring data according to a user-provided action. Using callbacks, the user can decide how she or he would like to be informed about data refreshing.


[Skip to ReadMe]

Properties

Versions0.1.7, 0.2.0, 0.2.0.2, 0.2.0.2
Change logNone available
Dependenciesbase (>=4.7 && <5), formatting, lifted-async, microlens, microlens-th, monad-control, monad-logger, safe-exceptions, stm, text [details]
LicenseBSD3
Copyright(c) 2017 Moritz Schulte
AuthorMoritz Schulte
Maintainermtesseract@silverratio.net
CategoryControl
Home pagehttps://github.com/mtesseract/async-refresh
Source repositoryhead: git clone https://github.com/mtesseract/async-refresh
UploadedThu Jun 29 17:36:52 UTC 2017 by mtesseract

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for async-refresh-0.2.0.2

[back to package description]

async-refresh Hackage version Stackage version Build Status

About

This is Haskell library implementing the logic for refreshing of expiring data according to user-provided actions.

Usage

Example

The following IO action produces a TVar which is updated every ten seconds to contain the current time (wrapped in an Either SomeException, because refreshing may fail).

periodicTimeUpdater :: IO (TVar (Either SomeException UTCTime))
periodicTimeUpdater = runStderrLoggingT $ do
  timeStore <- liftIO $ newTVarIO (Left (toException NotFound))
  let conf = newAsyncRefreshConf (RefreshResult <$> liftIO getCurrentTime <*> pure Nothing)
        & asyncRefreshConfSetLabel "CurrentTime updated every 10 seconds"
        & asyncRefreshConfSetDefaultInterval (10 * 10^3)
        & asyncRefreshConfSetCallback (liftIO . atomically . writeTVar timeStore . fmap refreshResult)
  _ <- newAsyncRefresh conf
  return timeStore