| Copyright | (c) Gargantext 2024-Present |
|---|---|
| License | AGPL |
| Maintainer | gargantext@iscpif.fr |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Async.Worker
Description
Asynchronous worker.
Synopsis
- data KillWorkerSafely = KillWorkerSafely
- run :: HasWorkerBroker b a => State b a -> IO ()
- runSingle :: HasWorkerBroker b a => State b a -> IO ()
- runSingle' :: HasWorkerBroker b a => State b a -> IO ()
- sendJob :: HasWorkerBroker b a => Broker b (Job a) -> Queue -> Job a -> IO (MessageId b)
- mkDefaultSendJob :: Broker b (Job a) -> Queue -> a -> Timeout -> SendJob b a
- mkDefaultSendJob' :: Broker b (Job a) -> Queue -> a -> SendJob b a
- sendJob' :: HasWorkerBroker b a => SendJob b a -> IO (MessageId b)
- data SendJob b a = SendJob {
- broker :: Broker b (Job a)
- queue :: Queue
- msg :: a
- delay :: TimeoutS
- archStrat :: ArchiveStrategy
- errStrat :: ErrorStrategy
- toStrat :: TimeoutStrategy
- timeout :: Timeout
- resendOnKill :: Bool
Documentation
data KillWorkerSafely Source #
If you want to stop a worker safely, use throwTo
workerThreadId KillWorkerSafely. This way the worker will stop
whatever is doing now and resend the message back to the
broker. This way you won't lose your jobs. If you don't care about
resuming a job, just set $sel:resendWhenWorkerKilled:JobMetadata property to
False.
Constructors
| KillWorkerSafely |
Instances
| Exception KillWorkerSafely Source # | |
Defined in Async.Worker Methods toException :: KillWorkerSafely -> SomeException # | |
| Show KillWorkerSafely Source # | |
Defined in Async.Worker Methods showsPrec :: Int -> KillWorkerSafely -> ShowS # show :: KillWorkerSafely -> String # showList :: [KillWorkerSafely] -> ShowS # | |
Running
run :: HasWorkerBroker b a => State b a -> IO () Source #
This is the main function to start a worker. It's an infinite loop of reading the next broker message, processing it and handling any errors, issues that might arrise in the meantime.
runSingle :: HasWorkerBroker b a => State b a -> IO () Source #
Fetch a single job and run it (create queue first)
runSingle' :: HasWorkerBroker b a => State b a -> IO () Source #
Fetch a single job and run it. Assumes the queue already exists
Sending jobs
SendJob wrappers
A worker job has quite a few metadata. Here are some utilities for constructing them more easily.
mkDefaultSendJob :: Broker b (Job a) -> Queue -> a -> Timeout -> SendJob b a Source #
Create a SendJob data with some defaults
mkDefaultSendJob' :: Broker b (Job a) -> Queue -> a -> SendJob b a Source #
Like mkDefaultSendJob but with default timeout