Safe Haskell | None |
---|
- data WorkQueue a
- type WorkHandler conn sess st a = a -> ErrorT InternalError (WebStateM conn sess st) WorkResult
- newWorker :: Int -> WorkHandler conn sess st a -> ErrorHandler a -> SpockM conn sess st (WorkQueue a)
- addWork :: MonadIO m => WorkExecution -> a -> WorkQueue a -> m ()
- data WorkExecution
- data WorkResult
- type ErrorHandler a = InternalError -> a -> IO WorkResult
- type InternalError = String
Worker
type WorkHandler conn sess st a = a -> ErrorT InternalError (WebStateM conn sess st) WorkResultSource
Describe how you want jobs in the queue to be performed
newWorker :: Int -> WorkHandler conn sess st a -> ErrorHandler a -> SpockM 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
type ErrorHandler a = InternalError -> a -> IO WorkResultSource
Describe how you want to handle errors. Make sure you catch all exceptions that can happen inside this handler, otherwise the worker will crash!
type InternalError = StringSource