haskell-bee-0.1.0.0: A lightweight library for asynchronous job workers with multiple broker backends
Copyright(c) Gargantext 2024-Present
LicenseAGPL
Maintainergargantext@iscpif.fr
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Async.Worker

Description

Asynchronous worker.

Synopsis

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 

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 :: HasWorkerBroker b a => Broker b (Job a) -> Queue -> Job a -> IO (MessageId b) Source #

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

sendJob' :: HasWorkerBroker b a => SendJob b a -> IO (MessageId b) Source #

Call sendJob with 'SendJob b a' data

data SendJob b a Source #

Wraps parameters for the sendJob function