arbiter-worker-testkit-0.1.0.0
arbiter-worker-testkit
Safe HaskellNone
LanguageGHC2024

Arbiter.Worker.TestKit

Description

Parameterized worker-pool test suite, instantiated for each MonadArbiter backend.

Synopsis

Documentation

Source #workerSpec :: (Eq payload, QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ Maybe [Text], Show payload) => (Text -> payload) -> (Int -> payload) -> ((JobRead payload -> m (ResultOf m payload)) -> JobHandler m payload (ResultOf m payload)) -> (forall a. env -> m a -> IO a) -> SpecWith env

Arguments

:: (Eq payload, QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ Maybe [Text], Show payload) 
=> (Text -> payload)

Construct a simple task payload

-> (Int -> payload)

Construct a failing task payload

-> ((JobRead payload -> m (ResultOf m payload)) -> JobHandler m payload (ResultOf m payload))

Adapt a job action into the backend's handler shape

-> (forall a. env -> m a -> IO a)

Runner function (e.g. runSimpleDb env or runOrvilleTest env)

-> SpecWith env 

Build a worker-pool test suite for the given MonadArbiter runner.

mkSimple/mkFailing construct the backend's payload, mkHandler adapts a plain job action into the backend's JobHandler shape (some backends pass a connection, others do not), and runM runs a backend action in IO.

The queue under test declares Maybe [Text] as its result type.

Source #listenerSpec :: forall payload m env. (QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ ()) => Text -> ByteString -> (Text -> payload) -> IO env -> IO env -> (env -> IO ()) -> ((JobRead payload -> m ()) -> JobHandler m payload ()) -> (forall a. env -> m a -> IO a) -> Spec

Arguments

:: forall payload m env. (QueueOperation m payload, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payload ~ ()) 
=> Text

Schema/table name, also the LISTEN channel prefix

-> ByteString

Connection string, for terminating the listener backend

-> (Text -> payload)

Construct a task payload

-> IO env

Create an env whose listener is enabled

-> IO env

Create an env with the listener disabled (poll-only)

-> (env -> IO ())

Release an env built by the actions above

-> ((JobRead payload -> m ()) -> JobHandler m payload ())

Adapt a job action into the backend's handler shape

-> (forall a. env -> m a -> IO a)

Runner function

-> Spec 

Env-owned LISTEN hub test suite, instantiated for each backend. Under a high pollInterval only the NOTIFY can wake the dispatcher in time. Completion proves the listener fired.

Source #multiQueueListenerSpec :: forall payloadA payloadB m env. (QueueOperation m payloadA, QueueOperation m payloadB, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payloadA ~ (), ResultOf m payloadB ~ ()) => Text -> Text -> ByteString -> (Text -> payloadA) -> (Text -> payloadB) -> IO env -> (env -> IO ()) -> (forall p. (JobRead p -> m ()) -> JobHandler m p ()) -> (forall a. env -> m a -> IO a) -> Spec

Arguments

:: forall payloadA payloadB m env. (QueueOperation m payloadA, QueueOperation m payloadB, RegistryAdmissionPolicies (RegistryOf m), RegistryTables (RegistryOf m), ResultOf m payloadA ~ (), ResultOf m payloadB ~ ()) 
=> Text

Queue A table name, also its LISTEN channel prefix

-> Text

Queue B table name, also its LISTEN channel prefix

-> ByteString

Connection string, for issuing a raw NOTIFY

-> (Text -> payloadA)

Construct a queue A payload

-> (Text -> payloadB)

Construct a queue B payload

-> IO env

Create an env whose listener is enabled, with both queue tables set up

-> (env -> IO ())

Release an env built by the action above

-> (forall p. (JobRead p -> m ()) -> JobHandler m p ())

Adapt a job action into the backend's handler shape

-> (forall a. env -> m a -> IO a)

Runner function

-> Spec 

Env-owned LISTEN hub test suite for two queues sharing one env, one worker pool per queue. Each queue's job-arrival channel is derived from its table name. These check that a shared hub wakes each pool for its own queue only. The registry must map payloadA to the tableA queue and payloadB to tableB.