Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data WorkQueue a
- type WorkHandler conn sess st a = a -> ErrorT InternalError (WebStateM conn sess st) WorkResult
- data WorkerConfig = WorkerConfig {}
- data WorkerConcurrentStrategy
- 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)
- addWork :: MonadIO m => WorkExecution -> a -> WorkQueue a -> m ()
- data WorkExecution
- data WorkResult
- data ErrorHandler conn sess st a
- = ErrorHandlerIO (InternalError -> a -> IO WorkResult)
- | ErrorHandlerSpock (InternalError -> a -> WebStateM conn sess st WorkResult)
- type InternalError = String
Worker
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!
ErrorHandlerIO (InternalError -> a -> IO WorkResult) | |
ErrorHandlerSpock (InternalError -> a -> WebStateM conn sess st WorkResult) |
type InternalError = String Source