powerqueue-0.1.0.0: A flexible job queue with exchangeable backends

Safe HaskellSafe
LanguageHaskell2010

Data.PowerQueue

Contents

Synopsis

Worker descriptions

data QueueWorker j Source #

Instances

data JobResult Source #

Result of the job

Constructors

JOk

job is complete

JRetry

job execution should be retried

Queue control

data Queue j Source #

newQueue :: QueueBackend j -> QueueWorker j -> Queue j Source #

Create a new queue description

mapQueue :: (a -> b) -> (b -> a) -> Queue a -> Queue b Source #

enqueueJob :: j -> Queue j -> IO Bool Source #

Add a Job to the Queue

(persistent) queue backends

data QueueBackend j Source #

Constructors

Monad m => QueueBackend 

Fields

  • qb_lift :: forall a. m a -> IO a

    lift an action from the backend monad into IO

  • qb_enqueue :: j -> m Bool

    enqueue a job

  • qb_dequeue :: m (tx, j)

    dequeue a single job, block if no job available

  • qb_confirm :: tx -> m ()

    mark a single job as confirmed

  • qb_rollback :: tx -> m ()

    mark a single job as failed

mapBackend :: (a -> b) -> (b -> a) -> QueueBackend a -> QueueBackend b Source #

basicChanBackend :: forall j. IO (QueueBackend j) Source #

A very basic in memory backend using only data structures from the base library. It should only be used for testing and serves as an implementation example

execution strategies

workStep :: Queue j -> IO () Source #

Execute a single work step: attempt a dequeue and run the job. Use to implement a queue worker, such as localQueueWorker

A local worker

localQueueWorker :: LocalWorkerConfig -> Queue j -> IO () Source #

(Concurrently) run pending jobs on local machine in current process