arbiter-worker-0.1.0.0
arbiter-worker
Safe HaskellNone
LanguageGHC2024

Arbiter.Worker.Heartbeat.Guard

Description

Internal to the arbiter packages. Not covered by the PVP.

One guard per pool. It fences every batch in flight and extends their leases. A batch registers through guardBatch. recheck asks for its extend now. runHeartbeatGuard is the loop that fences and extends.

Synopsis

Documentation

data HeartbeatGuard (n :: Type -> Type) jobSource #

The pool's heartbeat guard.

data GuardConfig (n :: Type -> Type) jobSource #

What the guard needs from the pool.

Constructors

GuardConfig 

Fields

newHeartbeatGuard :: MonadSTM n => GuardConfig n job -> n (HeartbeatGuard n job)Source #

A guard with no batches registered.

runHeartbeatGuard :: (MonadFork n, MonadMask n, MonadTime n, MonadTimer n) => HeartbeatGuard n job -> n VoidSource #

The guard loop. Fences what is due, then extends what is due.

guardKey :: forall (n :: Type -> Type) job. HeartbeatGuard n job -> job -> JobIdSource #

The key the guard tracks jobs by.

data Batch (n :: Type -> Type) jobSource #

A batch under guard.

Constructors

Batch 

Fields

guardBatch :: (MonadFork n, MonadMask n, MonadMonotonicTime n, MonadSTM n, MonadTime n) => HeartbeatGuard n job -> Batch n job -> n a -> n aSource #

Run action on the calling thread with the batch registered with the guard.

recheck :: (MonadMonotonicTime n, MonadSTM n) => HeartbeatGuard n job -> JobId -> n ()Source #

Extend the batch that holds the job now. The extend's verdict signals its handler.

trySync :: MonadCatch n => n a -> n (Either SomeException a)Source #

try for synchronous exceptions only.

toDiffTime :: NominalDiffTime -> DiffTimeSource #

A wall-clock span as a monotonic one.

minRetryPause :: DiffTimeSource #

Shortest gap between failed extends.

settleGrace :: DiffTimeSource #

Settle time a landed extend gets past its give-up.

leaseExpiredReason :: TextSource #

The reason a batch is stopped at its lease.

reclaimedReason :: TextSource #

The reason a batch another worker reclaimed is stopped.

deletedReason :: TextSource #

The reason a batch whose row was deleted under it is stopped.