hercules-ci-agent-0.9.10: Runs Continuous Integration tasks on your machines
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hercules.Agent.Producer

Synopsis

Documentation

data Producer p r Source #

A thread producing zero or more payloads and a final value. Handles exception propagation.

Constructors

Producer 

Instances

Instances details
Functor (Producer p) Source # 
Instance details

Defined in Hercules.Agent.Producer

Methods

fmap :: (a -> b) -> Producer p a -> Producer p b #

(<$) :: a -> Producer p b -> Producer p a #

data Msg p r Source #

Constructors

Payload p

One of possibly many payloads from the producer

Exception SomeException

The producer stopped due to an exception

Close r

The producer was done and produced a final value

Instances

Instances details
Functor (Msg p) Source # 
Instance details

Defined in Hercules.Agent.Producer

Methods

fmap :: (a -> b) -> Msg p a -> Msg p b #

(<$) :: a -> Msg p b -> Msg p a #

forkProducer :: forall m p r. (MonadIO m, MonadUnliftIO m) => ((p -> m ()) -> m r) -> m (Producer p r) Source #

forkProducer f produces a computation that forks a thread for f, which receives a function for returning payloads p.

f may produce a final result value r when it is done.

cancel :: MonadIO m => Producer p r -> m () Source #

Throws ProducerCancelled as an async exception to the producer thread. Blocks until exception is raised. See throwTo.

withProducer :: (MonadIO m, MonadUnliftIO m) => ((p -> m ()) -> m r) -> (Producer p r -> m a) -> m a Source #

Perform an computation while withProducer takes care of forking and cleaning up.

withProducer (write -> write "a" >> write "b") $ producer -> consume producer

listen :: MonadIO m => Producer p r -> (p -> m a) -> (r -> m a) -> STM (m a) Source #

joinSTM :: MonadIO m => STM (m a) -> m a Source #

data Syncing a Source #

Constructors

Syncable a 
Syncer (Maybe SomeException -> STM ()) 

withSync :: (MonadIO m, MonadUnliftIO m, Traversable t) => t (Syncing a) -> (t (Maybe a) -> m b) -> m b Source #

Sends sync notifications after the whole computation succeeds (or fails) Note: not exception safe in the presence of pure exceptions.

withBoundedDelayBatchProducer Source #

Arguments

:: (MonadIO m, MonadUnliftIO m, KatipContext m) 
=> Int

Max time before flushing in microseconds

-> Int

Max number of items in batch

-> Producer p r 
-> (Producer [p] r -> m a) 
-> m a 

syncer :: MonadIO m => (Syncing a -> m ()) -> m () Source #