arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.HighLevel

Description

The job queue operations with their table names resolved from the payload type. A payload reaches the queue its registry entry declares.

Synopsis

Constraint Aliases

Source #type QueueOperation (m :: Type -> Type) payload = (JobPayload payload, KnownSymbol (TableForPayload payload (RegistryOf m)), MonadArbiter m)

Constraints for queue operations (requires table name lookup from registry).

Source #type JobOperation (m :: Type -> Type) payload = (JobPayload payload, MonadArbiter m)

Constraints for job operations (table name stored in job).

Source #queueTable :: forall payload (m :: Type -> Type). KnownSymbol (TableForPayload payload (RegistryOf m)) => Text

The table name payload's entry in this monad's registry declares.

Source #type RegistryAdmissionPolicies (registry :: JobPayloadRegistry) = (RegistryConcurrencyPolicies registry, RegistryRateLimitPolicies registry)

The registry declares both admission policy kinds.

Job Operations

Source #insertJob :: forall payload m. QueueOperation m payload => JobWrite payload -> m (Maybe (JobRead payload))

Insert a job. Returns the inserted job, or Nothing if skipped by dedup (IgnoreDuplicate).

Source #insertJobsBatch :: forall payload m. QueueOperation m payload => [JobWrite payload] -> m [JobRead payload]

Insert multiple jobs in one round-trip. Returns the jobs that were inserted. Dedup'd jobs are excluded. Use insertJobTree for parent-child relationships.

Source #insertJobsBatch_ :: forall payload m. QueueOperation m payload => [JobWrite payload] -> m Int64

insertJobsBatch returning the count of inserted rows.

Source #claimNextVisibleJobs :: forall payload m. QueueOperation m payload => Int -> NominalDiffTime -> m [JobRead payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> Int

Maximum number of jobs to claim.

-> NominalDiffTime

How long the claimed jobs should remain invisible (in seconds).

-> m [JobRead payload] 

Claim visible jobs, at most one per group, and fewer than the limit once the groups run out. Stamps the anonymous claimant. A concurrency pool caps this path as it caps any other claim.

Source #claimNextVisibleJobsAs :: forall payload m. QueueOperation m payload => Int -> NominalDiffTime -> UUID -> m [JobRead payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> Int 
-> NominalDiffTime 
-> UUID

Worker UUID stamped on each claimed row.

-> m [JobRead payload] 

claimNextVisibleJobs under a given worker id. The dispatcher claims this way.

Source #claimNextVisibleJobsBatched :: forall payload m. QueueOperation m payload => Int -> Int -> NominalDiffTime -> m [NonEmpty (JobRead payload)]

Arguments

:: forall payload m. QueueOperation m payload 
=> Int

Batch size: maximum number of jobs to claim per group.

-> Int

Max groups: maximum number of groups/batches to claim.

-> NominalDiffTime

How long the claimed jobs should remain invisible (in seconds).

-> m [NonEmpty (JobRead payload)] 

claimNextVisibleJobs claiming up to batchSize jobs from each group, still in per-group order.

Source #mkClaimSql :: forall payload m. QueueOperation m payload => Int -> Int -> NominalDiffTime -> UUID -> m ClaimSql

Assemble a pool's claim statements once (see mkClaimSql). Batch size 1 is the single-job claim.

Source #addRateLimitTokens :: (MonadArbiter m, RegistryTables (RegistryOf m)) => RateLimitKey -> Double -> m ()

Add tokens to a key's bucket, capped at max, and wake any of its jobs parked mid-wait. A no-op without a policy.

Source #pruneRateLimitBuckets :: MonadArbiter m => NominalDiffTime -> m Int64

Delete reclaimable idle (full) buckets. Returns the number pruned. The worker reaper runs this. A full bucket re-seeds at full on next use.

Source #resetRateLimitBuckets :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Text -> m Int64

Reset every bucket for a prefix to full and wake its throttled jobs. Returns the number of buckets reset. A manual (0-refill) policy plus a cron calling this at the boundary is a fixed window.

Source #listRateLimitPolicies :: (MonadArbiter m, RegistryTables (RegistryOf m)) => m [RateLimitPolicyView]

List every rate-limit policy with its params, bucket stats, and a live count of currently-throttled jobs per prefix across the registry's queues.

Source #getRateLimitPolicy :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Text -> m (Maybe RateLimitPolicyView)

One prefix's rate-limit policy with its params, bucket stats, and live throttled count. Nothing when the prefix has no policy.

Source #rateLimitPolicyExists :: MonadArbiter m => Text -> m Bool

Whether a rate-limit policy exists for a prefix.

Source #listRateLimitBuckets :: MonadArbiter m => Text -> Int -> Int -> m [RateLimitBucketView]

List a prefix's buckets with fill levels, paginated.

Source #listConcurrencyPolicies :: MonadArbiter m => m [ConcurrencyPolicyView]

List every concurrency pool with its default/override limit and live key and in-flight aggregates.

Source #getConcurrencyPolicy :: MonadArbiter m => Text -> m (Maybe ConcurrencyPolicyView)

One prefix's concurrency pool with its default/override limit and live aggregates. Nothing when the prefix has no pool.

Source #listConcurrencyKeys :: MonadArbiter m => Text -> Int -> Int -> m [ConcurrencyKeyView]

List a prefix's keys with effective cap and in-flight fill fraction, paginated.

Source #updateRateLimitPolicyOverrides :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Text -> RateLimitPolicyUpdate -> m Int64

Set or clear a policy's override params and wake the prefix's parked jobs. Returns rows affected (0 if absent).

Source #setRateLimit :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Policy -> m Int64

Override a policy with this shape, until it is cleared. Returns rows affected.

Source #clearRateLimit :: (MonadArbiter m, RegistryTables (RegistryOf m)) => Policy -> m Int64

Drop a policy's overrides. Its declared params apply again. Returns rows affected.

Source #updateConcurrencyPolicyOverrides :: MonadArbiter m => Text -> ConcurrencyPolicyUpdate -> m Int64

Apply a pool's override-limit patch on its policy row, retuning every key under the prefix live. Lowering it does not preempt in-flight jobs until they drain. Returns rows affected.

Source #setConcurrencyLimit :: MonadArbiter m => ConcurrencyPolicy -> Int32 -> m Int64

Override a declared pool's limit for every key under it. Returns rows affected.

Source #clearConcurrencyLimit :: MonadArbiter m => ConcurrencyPolicy -> m Int64

Drop a pool's override. Its declared limit applies again. Returns rows affected.

Source #pruneConcurrencyKeys :: (MonadArbiter m, RegistryTables (RegistryOf m)) => m Int64

Delete drained concurrency rows with no live job. The reaper runs this.

Source #reconcileConcurrencyCounts :: (MonadArbiter m, RegistryTables (RegistryOf m)) => m Int64

Recompute the concurrency counts from live jobs, repairing any trigger drift.

Source #reconcileConcurrencyCountsIfStale :: (MonadArbiter m, RegistryTables (RegistryOf m)) => m Int64

Rebuild the concurrency counts when a crash truncated the UNLOGGED table. The reaper runs this periodically.

Source #reconcileAndPruneConcurrency :: (MonadArbiter m, RegistryTables (RegistryOf m)) => m Int64

Reconcile then prune. The reaper runs this.

Source #ackJob :: forall payload m. JobOperation m payload => JobRead payload -> m Int64

Ack a completed job, deleting it or suspending it when its children are still running. Returns 1, or 0 for a job already gone.

Source #ackJobsBatch :: forall payload m. JobOperation m payload => [JobRead payload] -> m [Int64]

ackJob over a batch from one queue in one statement, returning the ids acked. Reclaimed jobs are absent.

Source #updateJobForRetry :: forall payload m. JobOperation m payload => NominalDiffTime -> Text -> JobRead payload -> m Int64

Arguments

:: forall payload m. JobOperation m payload 
=> NominalDiffTime

The delay before this job becomes visible again for retry.

-> Text

An error message to store with the job.

-> JobRead payload 
-> m Int64 

Park a failed job for its retry backoff. Returns 0 for a job another worker holds.

Source #nackJob :: forall payload m. JobOperation m payload => JobRead payload -> m Int64

Soft-nack a job. It is reprocessed once its visibility timeout lapses. No failure is recorded and no attempt is consumed. Returns 0 for a job another worker holds.

Source #nackJobsBatch :: forall payload m. JobOperation m payload => [JobRead payload] -> m [Int64]

nackJob over a batch from one queue in one statement, returning the ids nacked. Jobs another worker holds are absent.

Source #setVisibilityTimeout :: forall payload m. JobOperation m payload => NominalDiffTime -> JobRead payload -> m Int64

Arguments

:: forall payload m. JobOperation m payload 
=> NominalDiffTime

The new visibility timeout (in seconds) from the current time.

-> JobRead payload 
-> m Int64 

Extend a job's visibility timeout by hand, for a long-running job. Returns 0 for a job that is gone, reclaimed or suspended. setVisibilityTimeoutBatch tells them apart.

Source #setVisibilityTimeoutBatch :: forall payload m. JobOperation m payload => NominalDiffTime -> [JobRead payload] -> m [SetVisibilityResult]

Arguments

:: forall payload m. JobOperation m payload 
=> NominalDiffTime

The new visibility timeout (in seconds) from the current time.

-> [JobRead payload]

Jobs to heartbeat (all must be from the same queue)

-> m [SetVisibilityResult] 

setVisibilityTimeout over a batch from one queue.

Source #data SetVisibilityResult

Result of setting visibility timeout for a single job in a batch.

Constructors

VisibilityExtended JobId

Visibility timeout was successfully extended.

JobGone JobId

Job no longer exists (was deleted/acked).

JobReclaimed JobId ClaimSeq ClaimSeq

Job was reclaimed by another worker. Carries this claim's token, then the row's current token.

JobCancelled JobId

Job was force-cancel-flagged.

JobSuspended JobId

Job is a finalizer waiting on its children. It holds no lease.

VisibilityUnchanged JobId

The row changed under this claim mid-statement. Nothing was extended.

Filtered Query Operations

Source #listJobsFiltered :: forall payload m. QueueOperation m payload => [JobFilter] -> Int -> Int -> m [JobRead payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> [JobFilter]

Composable filters

-> Int

Limit

-> Int

Offset

-> m [JobRead payload] 

List filtered jobs, newest first.

Source #countJobsFiltered :: forall payload m. QueueOperation m payload => [JobFilter] -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> [JobFilter]

Composable filters

-> m Int64 

Count filtered jobs.

Source #listDLQFiltered :: forall payload m. QueueOperation m payload => [JobFilter] -> Int -> Int -> m [DLQJob payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> [JobFilter]

Composable filters

-> Int

Limit

-> Int

Offset

-> m [DLQJob payload] 

List filtered DLQ jobs, most recently failed first.

Source #countDLQFiltered :: forall payload m. QueueOperation m payload => [JobFilter] -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> [JobFilter]

Composable filters

-> m Int64 

Count filtered DLQ jobs.

Dead Letter Queue Operations

Source #moveToDLQ :: forall payload m. JobOperation m payload => Text -> JobRead payload -> m Int64

Arguments

:: forall payload m. JobOperation m payload 
=> Text

Error message (the final error that caused the DLQ move)

-> JobRead payload 
-> m Int64 

Move a job to the DLQ. Returns 0 for a job another worker holds.

Source #moveToDLQBatch :: forall payload m. JobOperation m payload => [(JobRead payload, Text)] -> m Int64

Arguments

:: forall payload m. JobOperation m payload 
=> [(JobRead payload, Text)]

List of (job, error message) pairs. All jobs must be from the same queue.

-> m Int64 

Move a batch of jobs to the DLQ, skipping any another worker holds. Returns the number moved.

Source #listDLQJobs :: forall payload m. QueueOperation m payload => Int -> Int -> m [DLQJob payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> Int

Limit

-> Int

Offset

-> m [DLQJob payload] 

List DLQ jobs, most recently failed first.

Source #listArchiveJobs :: forall payload m. QueueOperation m payload => Int -> Int -> m [ArchiveJob payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> Int

Limit

-> Int

Offset

-> m [ArchiveJob payload] 

List archived jobs, most recently completed first.

Source #getArchivedJobById :: forall payload m. QueueOperation m payload => Int64 -> m (Maybe (ArchiveJob payload))

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Original job id

-> m (Maybe (ArchiveJob payload)) 

Fetch a single archived job by its original job id.

Source #listArchivedJobsByGroupKey :: forall payload m. QueueOperation m payload => Text -> Int -> Int -> m [ArchiveJob payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> Text

Group key

-> Int

Limit

-> Int

Offset

-> m [ArchiveJob payload] 

List archived jobs in a group, most recent first, with pagination.

Source #deleteArchiveJob :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Archive primary key

-> m Int64 

Delete one archived job by its archive primary key. Returns rows deleted.

Source #deleteArchiveJobsBatch :: forall payload m. QueueOperation m payload => [Int64] -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> [Int64]

Archive primary keys

-> m Int64 

Delete archived jobs by archive primary key. Returns rows deleted.

Source #reEnqueueFromArchive :: forall payload m. QueueOperation m payload => Int64 -> m (Maybe (JobRead payload))

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Archive primary key

-> m (Maybe (JobRead payload)) 

Re-enqueue an archived job as a fresh standalone job, keeping the archive row. Returns the new job, or Nothing if the archive row no longer exists.

Source #retryFromDLQ :: forall payload m. QueueOperation m payload => Int64 -> m (Maybe (JobRead payload))

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

DLQ job id

-> m (Maybe (JobRead payload)) 

Retry a DLQ job, re-inserting it into the queue with a fresh attempt count. Nothing when the DLQ row is gone.

Source #dlqJobExists :: forall payload m. QueueOperation m payload => Int64 -> m Bool

Whether a DLQ job with the given id exists.

Source #deleteDLQJob :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

DLQ job id

-> m Int64 

Delete a DLQ job. Returns 0 when the row is already gone.

Source #deleteDLQJobsBatch :: forall payload m. QueueOperation m payload => [Int64] -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> [Int64]

DLQ job ids

-> m Int64 

Delete DLQ jobs by id. Returns the number deleted.

Admin Operations

Source #listJobs :: forall payload m. QueueOperation m payload => Int -> Int -> m [JobRead payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> Int

Limit

-> Int

Offset

-> m [JobRead payload] 

List jobs, newest first.

Source #getJobById :: forall payload m. QueueOperation m payload => Int64 -> m (Maybe (JobRead payload))

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Job id

-> m (Maybe (JobRead payload)) 

Fetch a job by id.

Source #jobExists :: forall payload m. QueueOperation m payload => Int64 -> m Bool

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Job id

-> m Bool 

Whether a job with the given id exists in this payload's queue table.

Source #getJobsByGroup :: forall payload m. QueueOperation m payload => Text -> Int -> Int -> m [JobRead payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> Text

Group key

-> Int

Limit

-> Int

Offset

-> m [JobRead payload] 

List a group's jobs.

Source #getJobsByParent :: forall payload m. QueueOperation m payload => Int64 -> Int -> Int -> m [JobRead payload]

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Parent id

-> Int

Limit

-> Int

Offset

-> m [JobRead payload] 

List a parent's children.

Source #cancelJob :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Job id

-> m Int64 

Delete a job by id. Returns 0 for a job with children. cancelJobCascade deletes those.

Source #cancelJobsBatch :: forall payload m. QueueOperation m payload => [Int64] -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> [Int64]

Job ids

-> m Int64 

Delete jobs by id. Returns the number deleted.

Source #forceCancelJob :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Root job id

-> m Int64 

Delete a job and its descendants, interrupting any handler running one of them by NOTIFY on the cancel channel.

Source #promoteJob :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Job id

-> m Int64 

Make a delayed or retrying job immediately visible. Refuses an in-flight job.

Source #data QueueStats

Per-status breakdown of a queue. The per-status counts partition the queue and sum to totalJobs, mirroring the derived job status taxonomy.

Constructors

QueueStats 

Fields

Instances

Instances details
FromJSON QueueStats Source # 
Instance details

Defined in Arbiter.Core.Operations

ToJSON QueueStats Source # 
Instance details

Defined in Arbiter.Core.Operations

Eq QueueStats Source # 
Instance details

Defined in Arbiter.Core.Operations

Generic QueueStats Source # 
Instance details

Defined in Arbiter.Core.Operations

Associated Types

type Rep QueueStats 
Instance details

Defined in Arbiter.Core.Operations

type Rep QueueStats = D1 ('MetaData "QueueStats" "Arbiter.Core.Operations" "arbiter-core-0.1.0.0-inplace" 'False) (C1 ('MetaCons "QueueStats" 'PrefixI 'True) (((S1 ('MetaSel ('Just "totalJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: (S1 ('MetaSel ('Just "readyJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: S1 ('MetaSel ('Just "inFlightJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64))) :*: (S1 ('MetaSel ('Just "scheduledJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: (S1 ('MetaSel ('Just "backoffJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: S1 ('MetaSel ('Just "throttledJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))) :*: ((S1 ('MetaSel ('Just "suspendedJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: (S1 ('MetaSel ('Just "cancelledJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: S1 ('MetaSel ('Just "oldestReadyAgeSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Double)))) :*: (S1 ('MetaSel ('Just "oldestInFlightAgeSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Double)) :*: (S1 ('MetaSel ('Just "dlqJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: S1 ('MetaSel ('Just "kindCounts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Text Int64)))))))
Show QueueStats Source # 
Instance details

Defined in Arbiter.Core.Operations

type Rep QueueStats Source # 
Instance details

Defined in Arbiter.Core.Operations

type Rep QueueStats = D1 ('MetaData "QueueStats" "Arbiter.Core.Operations" "arbiter-core-0.1.0.0-inplace" 'False) (C1 ('MetaCons "QueueStats" 'PrefixI 'True) (((S1 ('MetaSel ('Just "totalJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: (S1 ('MetaSel ('Just "readyJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: S1 ('MetaSel ('Just "inFlightJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64))) :*: (S1 ('MetaSel ('Just "scheduledJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: (S1 ('MetaSel ('Just "backoffJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: S1 ('MetaSel ('Just "throttledJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))) :*: ((S1 ('MetaSel ('Just "suspendedJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: (S1 ('MetaSel ('Just "cancelledJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: S1 ('MetaSel ('Just "oldestReadyAgeSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Double)))) :*: (S1 ('MetaSel ('Just "oldestInFlightAgeSeconds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Double)) :*: (S1 ('MetaSel ('Just "dlqJobs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64) :*: S1 ('MetaSel ('Just "kindCounts") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Text Int64)))))))

Source #getQueueStats :: forall payload m. QueueOperation m payload => m QueueStats

A queue's per-status counts and backlog ages.

Count Operations

Source #countJobs :: forall payload m. QueueOperation m payload => m Int64

Count every job in the queue.

Source #countJobsByGroup :: forall payload m. QueueOperation m payload => Text -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Text

Group key

-> m Int64 

Count a group's jobs.

Source #countJobsByParent :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Parent id

-> m Int64 

Count a parent's children.

Source #countDLQJobs :: forall payload m. QueueOperation m payload => m Int64

Count the queue's DLQ jobs.

Source #countChildrenBatch :: forall payload m. QueueOperation m payload => [Int64] -> m (Map Int64 (Int64, Int64))

Child counts as (total, paused) per parent id, over a batch. Parents with none are absent.

Source #countDLQChildren :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Parent job id

-> m Int64 

Count a parent's DLQ'd children.

Source #countDLQChildrenBatch :: forall payload m. QueueOperation m payload => [Int64] -> m (Map Int64 Int64)

DLQ child counts per parent id, over a batch. Parents with none are absent.

Job Dependency Operations

Source #pauseChildren :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Parent job id

-> m Int64 

Suspend a parent's claimable children. In-flight ones are left alone. Returns the number suspended.

Source #resumeChildren :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Parent job id

-> m Int64 

Resume a parent's suspended children. Returns the number resumed.

Source #cancelJobCascade :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Root job id

-> m Int64 

Delete a job and every descendant under it. Returns the number deleted.

Suspend/Resume Operations

Source #suspendJob :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Job id

-> m Int64 

Suspend a job, making it unclaimable. Refuses an in-flight job.

Source #resumeJob :: forall payload m. QueueOperation m payload => Int64 -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Job id

-> m Int64 

Resume a suspended job, making it claimable again.

Results Table Operations

Source #insertResult :: forall payload m. (EncodeJobResult (ResultOf m payload), QueueOperation m payload) => Int64 -> Int64 -> ResultOf m payload -> m Int64

Arguments

:: forall payload m. (EncodeJobResult (ResultOf m payload), QueueOperation m payload) 
=> Int64

Parent job id

-> Int64

Child job id

-> ResultOf m payload

Result value

-> m Int64 

Insert a child's result, encoded as the queue's declared result type and keyed by (parent_id, child_id). Its foreign key cascades. Acking the parent clears it. Returns 0 for a result that stores nothing.

Source #insertResultUnsafe :: forall payload m. QueueOperation m payload => Int64 -> Int64 -> Value -> m Int64

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Parent job id

-> Int64

Child job id

-> Value

Encoded result value

-> m Int64 

insertResult with a raw JSON value, bypassing the queue's declared result type. A value childResults cannot decode surfaces there as a Left.

Source #getResultsByParent :: forall payload m. QueueOperation m payload => Int64 -> m (Map Int64 Value)

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Parent job id

-> m (Map Int64 Value) 

A parent's child results, keyed by child id.

Source #getDLQChildErrorsByParent :: forall payload m. QueueOperation m payload => Int64 -> m (Map Int64 Text)

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Parent job id

-> m (Map Int64 Text) 

A parent's DLQ'd children's last errors, keyed by child id.

Source #readChildResultsRaw :: forall payload m. QueueOperation m payload => Int64 -> m (Map Int64 Value, Map Int64 Text, Maybe Value, Map Int64 Text)

Arguments

:: forall payload m. QueueOperation m payload 
=> Int64

Parent job id

-> m (Map Int64 Value, Map Int64 Text, Maybe Value, Map Int64 Text) 

Read all child data for a rollup finalizer. Returns (childId->result, childId->error, parentStateSnapshot, dlqRowId->error).

Source #mergeRawChildResults :: Map Int64 Value -> Map Int64 Text -> Maybe Value -> Map Int64 (Either Text Value)

Merge child results, DLQ errors and the snapshot, left-biased in that order.

Source #persistParentState :: forall payload m. QueueOperation m payload => Int64 -> Value -> m Int64

Snapshot results into parent_state before DLQ move.

Source #getParentStateSnapshot :: forall payload m. QueueOperation m payload => Int64 -> m (Maybe Value)

Read raw parent_state snapshot from the DB.

Groups Table Operations

Source #refreshAllGroupsFully :: (MonadArbiter m, RegistryTables (RegistryOf m)) => m (Int64, [Text])

Schema-wide groups-table refresh, correcting every registered queue's summary drift. Walks each groups table to the end, one bounded batch and one transaction at a time. This is a repair operation. The reaper runs refreshAllGroups for a single batch per tick. Returns the rows rewritten and the queue names that failed.

Worker Registry Operations

Source #registerWorker :: MonadArbiter m => UUID -> Text -> Maybe Text -> Maybe Int32 -> NominalDiffTime -> Maybe Value -> m (Maybe Bool)

Register or refresh a worker and return its effective pause state.

Source #heartbeatWorker :: MonadArbiter m => UUID -> m (Maybe Bool)

Record a heartbeat and return the worker's effective pause state.

Source #setWorkerPaused :: MonadArbiter m => UUID -> Bool -> m Int64

Set a worker's pause flag.

Source #markWorkerShuttingDown :: MonadArbiter m => UUID -> m Int64

Mark a worker as gracefully draining.

Source #deregisterWorker :: MonadArbiter m => UUID -> m Int64

Remove a worker registry row.

Source #listWorkers :: MonadArbiter m => Maybe Text -> Maybe NominalDiffTime -> m [WorkerRow]

List workers, optionally filtered by queue and heartbeat age.

Source #sweepStaleWorkers :: MonadArbiter m => m Int64

Delete workers older than their recorded stale threshold.

Source #data WorkerRow

A row in the worker registry. One row per running worker pool.

Instances

Instances details
FromJSON WorkerRow Source # 
Instance details

Defined in Arbiter.Core.Worker

ToJSON WorkerRow Source # 
Instance details

Defined in Arbiter.Core.Worker

Eq WorkerRow Source # 
Instance details

Defined in Arbiter.Core.Worker

Generic WorkerRow Source # 
Instance details

Defined in Arbiter.Core.Worker

Show WorkerRow Source # 
Instance details

Defined in Arbiter.Core.Worker

type Rep WorkerRow Source # 
Instance details

Defined in Arbiter.Core.Worker

Queue Operations

Source #ensureQueue :: MonadArbiter m => Text -> m Int64

Ensure a queue registry row exists.

Source #setQueuePaused :: MonadArbiter m => Text -> Bool -> m Int64

Set a queue's pause flag and notify its workers.

Source #getQueue :: MonadArbiter m => Text -> m (Maybe QueueRow)

Get one queue registry row.

Source #listQueues :: MonadArbiter m => m [QueueRow]

List all queues registered in the schema.

Source #data QueueRow

A row of the arbiter_queues pause/resume table.

Instances

Instances details
FromJSON QueueRow Source # 
Instance details

Defined in Arbiter.Core.Queues

ToJSON QueueRow Source # 
Instance details

Defined in Arbiter.Core.Queues

Eq QueueRow Source # 
Instance details

Defined in Arbiter.Core.Queues

Generic QueueRow Source # 
Instance details

Defined in Arbiter.Core.Queues

Associated Types

type Rep QueueRow 
Instance details

Defined in Arbiter.Core.Queues

Show QueueRow Source # 
Instance details

Defined in Arbiter.Core.Queues

type Rep QueueRow Source # 
Instance details

Defined in Arbiter.Core.Queues

Cron Schedule Operations

Source #listCronSchedules :: MonadArbiter m => Maybe Text -> m [CronScheduleRow]

Arguments

:: MonadArbiter m 
=> Maybe Text

Queue filter. Nothing returns schedules for all queues.

-> m [CronScheduleRow] 

List cron schedules ordered by name, optionally filtered by queue.

Source #getCronScheduleByName :: MonadArbiter m => Text -> m (Maybe CronScheduleRow)

Arguments

:: MonadArbiter m 
=> Text

Schedule name

-> m (Maybe CronScheduleRow) 

Get a single cron schedule by name.

Source #updateCronScheduleUnchecked :: MonadArbiter m => Text -> CronScheduleUpdate -> m Int64

Arguments

:: MonadArbiter m 
=> Text

Schedule name

-> CronScheduleUpdate 
-> m Int64 

Patch a cron schedule, writing the overrides as given. Returns rows affected, 0 for a name that is not there. Arbiter.Worker.updateCronScheduleChecked rejects overrides the scheduler cannot parse.

Global Gate

Source #runGated :: MonadArbiter m => Text -> NominalDiffTime -> m a -> m (Maybe a)

Arguments

:: MonadArbiter m 
=> Text

Task identifier

-> NominalDiffTime 
-> m a 
-> m (Maybe a) 

Run work at most once per interval across every worker pool sharing the same schema. See runGated.

Job Tree DSL

Source #insertJobTree :: forall payload m. QueueOperation m payload => JobTree payload -> m (Either Text (NonEmpty (JobRead payload)))

Insert a JobTree atomically. Returns all inserted jobs (pre-order), or Left if the root has a dedup conflict. Rolls back on any failure.

Re-exports

Source #getSchema :: MonadArbiter m => m SchemaName

The schema name for this monad's Arbiter tables.