Spock-worker-0.2.1.3: Background workers for Spock

Safe HaskellNone
LanguageHaskell2010

Web.Spock.Worker

Contents

Synopsis

Worker

data WorkQueue a Source

The queue containing scheduled jobs

type WorkHandler conn sess st a = a -> ErrorT InternalError (WebStateM conn sess st) WorkResult Source

Describe how you want jobs in the queue to be performed

data WorkerConfig Source

Configure how the worker handles it's task and define the queue size

data WorkerConcurrentStrategy Source

Configure the concurrent behaviour of a worker. If you want tasks executed concurrently, consider using WorkerConcurrentBounded

newWorker :: (MonadTrans t, Monad (t (WebStateM conn sess st))) => WorkerConfig -> WorkHandler conn sess st a -> ErrorHandler conn sess st a -> t (WebStateM conn sess st) (WorkQueue a) Source

Create a new background worker and limit the size of the job queue.

addWork :: MonadIO m => WorkExecution -> a -> WorkQueue a -> m () Source

Add a new job to the background worker. If the queue is full this will block

data WorkExecution Source

Describes when a job should be executed

data WorkResult Source

Describes the outcome of a job after completion. You can repeat jobs

Error Handeling

data ErrorHandler conn sess st a Source

Describe how you want to handle errors. Make sure you catch all exceptions that can happen inside this handler, otherwise the worker will crash!