arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.Jobs

Description

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

Jobs SQL templates.

Synopsis

Documentation

data JobFilterSource #

A narrowing predicate on a job listing. Filters combine with AND.

Constructors

FilterGroupKey Text

Jobs in this group.

FilterParentId Int64

Children of this parent.

FilterRootsOnly

Jobs with no parent.

FilterStatus JobStatus

Jobs with this derived status. Matches nothing on the DLQ or archive.

FilterId Int64

The row with this primary key.

FilterJobId Int64

The row with this original job id. On the main table, the row with this id.

FilterClaimedBy UUID

Jobs claimed by this worker.

FilterKind Text

Jobs with this kind label.

FilterPayloadText Text

Jobs whose payload text holds this substring, ignoring case.

FilterErrorText Text

Jobs whose last error holds this substring, ignoring case.

FilterRateLimitPrefix Text

Jobs under this rate-limit prefix.

FilterConcurrencyPrefix Text

Jobs under this concurrency prefix.

FilterInsertedAfter UTCTime

Jobs inserted at or after this time.

FilterInsertedBefore UTCTime

Jobs inserted before this time.

FilterCompletedAfter UTCTime

Jobs completed at or after this time. Matches nothing outside the archive.

FilterCompletedBefore UTCTime

Jobs completed before this time. Matches nothing outside the archive.

Instances

Instances details
Eq JobFilter Source # 
Instance details

Defined in Arbiter.Core.Sql.Jobs

Show JobFilter Source # 
Instance details

Defined in Arbiter.Core.Sql.Jobs

data FilterTableSource #

The table a JobFilter narrows.

Instances

Instances details
Eq FilterTable Source # 
Instance details

Defined in Arbiter.Core.Sql.Jobs

Show FilterTable Source # 
Instance details

Defined in Arbiter.Core.Sql.Jobs

jobSortColumnName :: JobSortColumn -> TextSource #

Underlying SQL column name for a JobSortColumn.

data DLQSortColumnSource #

Sortable columns on the DLQ table. DlqId is the DLQ primary key and DlqJobId the original job id.

Constructors

DlqId

By id, the DLQ primary key.

DlqFailedAt

By failed_at.

DlqJobId

By job_id, the original job id.

DlqPriority

By priority.

DlqAttempts

By attempts.

DlqInsertedAt

By inserted_at.

DlqGroupKey

By group_key.

DlqParentId

By parent_id.

DlqLastAttemptedAt

By last_attempted_at.

dlqSortColumnName :: DLQSortColumn -> TextSource #

The DLQ column a sort key names.

data ArchiveSortColumnSource #

Sortable columns on the archive table. ArchiveId is the archive primary key and ArchiveJobId the original job id.

Constructors

ArchiveId

By id, the archive primary key.

ArchiveCompletedAt

By completed_at.

ArchiveInsertedAt

By inserted_at.

ArchiveJobId

By job_id, the original job id.

ArchiveAttempts

By attempts.

ArchiveGroupKey

By group_key.

ArchiveParentId

By parent_id.

archiveSortColumnName :: ArchiveSortColumn -> TextSource #

The archive column a sort key names.

data SortDirSource #

Sort direction.

Constructors

SortAsc

Ascending.

SortDesc

Descending.

Instances

Instances details
Eq SortDir Source # 
Instance details

Defined in Arbiter.Core.Sql.Jobs

Methods

(==) :: SortDir -> SortDir -> Bool#

(/=) :: SortDir -> SortDir -> Bool#

Bounded SortDir Source # 
Instance details

Defined in Arbiter.Core.Sql.Jobs

Enum SortDir Source # 
Instance details

Defined in Arbiter.Core.Sql.Jobs

Show SortDir Source # 
Instance details

Defined in Arbiter.Core.Sql.Jobs

sortDirName :: SortDir -> TextSource #

A sort direction as a query parameter.

throttledPredicateSQL :: TextSource #

A throttle-deferred job with a live marker, still parked. Claiming clears the marker.

jobStatusCaseSQL :: TextSource #

The derived job status. Its string values match jobStatusToText. An exhausted job is visible but out of attempts, awaiting the reaper's DLQ sweep.

claimablePred :: Text -> TextSource #

The rows a claim considers, over a row alias: unsuspended, uncancelled, visible, and within the attempt budget.

listJobsFilteredSQL :: SchemaName -> TableName -> Query () -> Text -> Int64 -> Int64 -> Query (JobRead (Stored payload))Source #

List filtered jobs without the derived status.

listJobsWithStatusSQL :: SchemaName -> TableName -> Query () -> Text -> Int64 -> Int64 -> Query ()Source #

List filtered jobs with status as a trailing column. The caller attaches the row decoder.

countJobsFilteredSQL :: SchemaName -> TableName -> Query () -> Query Int64Source #

Count filtered jobs through the status subquery.

getJobByIdWithStatusSQL :: SchemaName -> TableName -> Int64 -> Query ()Source #

Fetch a single job by id with its derived status trailing column. The caller attaches the row decoder.

buildJobsOrderBy :: Maybe JobSortColumn -> Maybe SortDir -> TextSource #

ORDER BY for the jobs table. Defaults to id DESC.

buildDLQOrderBy :: Maybe DLQSortColumn -> Maybe SortDir -> TextSource #

ORDER BY for the DLQ table. Defaults to failed_at DESC.

buildArchiveOrderBy :: Maybe ArchiveSortColumn -> Maybe SortDir -> TextSource #

ORDER BY for the archive table. Defaults to completed_at DESC.

countWhereSQL :: Text -> Query () -> Query Int64Source #

Count the rows of src under a dynamic WHERE.

buildWhereClause :: FilterTable -> [JobFilter] -> Query ()Source #

The WHERE clause a set of filters narrows a listing of one table by. Empty for no filters.

jobColsExceptId :: TextSource #

The job read columns except id. The archive INSERT copies them with the main table's id as job_id.

dlqCarriedCols :: TextSource #

Job columns carried through a DLQ round-trip. The read columns except id and last_error, plus write-only rate_limit_cost.

requeuedCols :: TextSource #

The job columns a DLQ retry carries back to the main table, as a column list.

requeuedValsEditing :: [Text] -> (Text -> Text) -> TextSource #

requeuedCols as select expressions, with the attempt limit clamped. Each column in edited is read through reader.

enqueuedAgainCols :: TextSource #

The job columns an archive re-enqueue carries, as a column list. No parent link.

enqueuedAgainValsEditing :: [Text] -> (Text -> Text) -> TextSource #

enqueuedAgainCols as select expressions, with the attempt limit clamped. Each column in edited is read through reader.

jobReadColumns :: TextSource #

The job read columns, in codec order, for SELECT and RETURNING.

insertJobSQL :: SchemaName -> TableName -> Query () -> Query (JobRead (Stored payload))Source #

Insert a job. The write fragment carries the column list and parameters.

insertJobReplaceSQL :: SchemaName -> TableName -> Query () -> Query (JobRead (Stored payload))Source #

Insert under the replace dedup strategy. Replaces an existing job that is idle and childless in the main queue and the DLQ. ON CONFLICT DO UPDATE fires the groups UPDATE trigger, which maintains a cross-group move.

insertJobsBatchSQL :: SchemaName -> TableName -> Query () -> Query (JobRead (Stored payload))Source #

Batch insert over unnested parallel arrays. An ignore-dedup job is skipped on conflict. A replace-dedup job updates an idle existing row. A row whose parent is absent is skipped.

getJobByIdSQL :: SchemaName -> TableName -> Int64 -> Query (JobRead (Stored payload))Source #

Fetch a job by id.

getJobByDedupKeySQL :: SchemaName -> TableName -> Text -> Query (JobRead (Stored payload))Source #

Fetch a job by its dedup key. The partial unique index guarantees at most one row.

cancelJobSQL :: SchemaName -> TableName -> Int64 -> Query Int64Source #

Delete a job by id. Refuses one with children, which cancelJobCascadeSQL takes. A deleted child with no siblings left resumes its parent for a completion round.

unionAllOverQueueTables :: SchemaName -> [TableName] -> (TableName -> Text -> Text) -> TextSource #

UNION ALL of body over each job table, passing its raw name and schema-qualified reference.