| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Core.Sql.Jobs
Description
Internal to the arbiter packages. Not covered by the PVP.
Jobs SQL templates.
Synopsis
- data JobFilter
- = FilterGroupKey Text
- | FilterParentId Int64
- | FilterRootsOnly
- | FilterStatus JobStatus
- | FilterId Int64
- | FilterJobId Int64
- | FilterClaimedBy UUID
- | FilterKind Text
- | FilterPayloadText Text
- | FilterErrorText Text
- | FilterRateLimitPrefix Text
- | FilterConcurrencyPrefix Text
- | FilterInsertedAfter UTCTime
- | FilterInsertedBefore UTCTime
- | FilterCompletedAfter UTCTime
- | FilterCompletedBefore UTCTime
- data FilterTable
- data JobSortColumn
- jobSortColumnName :: JobSortColumn -> Text
- data DLQSortColumn
- dlqSortColumnName :: DLQSortColumn -> Text
- data ArchiveSortColumn
- archiveSortColumnName :: ArchiveSortColumn -> Text
- data SortDir
- sortDirName :: SortDir -> Text
- throttledPredicateSQL :: Text
- jobStatusCaseSQL :: Text
- claimablePred :: Text -> Text
- listJobsFilteredSQL :: SchemaName -> TableName -> Query () -> Text -> Int64 -> Int64 -> Query (JobRead (Stored payload))
- listJobsWithStatusSQL :: SchemaName -> TableName -> Query () -> Text -> Int64 -> Int64 -> Query ()
- countJobsFilteredSQL :: SchemaName -> TableName -> Query () -> Query Int64
- getJobByIdWithStatusSQL :: SchemaName -> TableName -> Int64 -> Query ()
- buildJobsOrderBy :: Maybe JobSortColumn -> Maybe SortDir -> Text
- buildDLQOrderBy :: Maybe DLQSortColumn -> Maybe SortDir -> Text
- buildArchiveOrderBy :: Maybe ArchiveSortColumn -> Maybe SortDir -> Text
- countWhereSQL :: Text -> Query () -> Query Int64
- buildWhereClause :: FilterTable -> [JobFilter] -> Query ()
- jobColsExceptId :: Text
- dlqCarriedCols :: Text
- requeuedCols :: Text
- requeuedValsEditing :: [Text] -> (Text -> Text) -> Text
- enqueuedAgainCols :: Text
- enqueuedAgainValsEditing :: [Text] -> (Text -> Text) -> Text
- jobReadColumns :: Text
- insertJobSQL :: SchemaName -> TableName -> Query () -> Query (JobRead (Stored payload))
- insertJobReplaceSQL :: SchemaName -> TableName -> Query () -> Query (JobRead (Stored payload))
- insertJobsBatchSQL :: SchemaName -> TableName -> Query () -> Query (JobRead (Stored payload))
- insertJobsBatchSQL_ :: SchemaName -> TableName -> Query () -> Query ()
- getJobByIdSQL :: SchemaName -> TableName -> Int64 -> Query (JobRead (Stored payload))
- getJobByDedupKeySQL :: SchemaName -> TableName -> Text -> Query (JobRead (Stored payload))
- cancelJobSQL :: SchemaName -> TableName -> Int64 -> Query Int64
- unionAllOverQueueTables :: SchemaName -> [TableName] -> (TableName -> Text -> Text) -> Text
Documentation
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. |
data FilterTableSource #
The table a JobFilter narrows.
Constructors
| MainTable | |
| DLQTable | |
| ArchiveTable |
Instances
| Eq FilterTable Source # | |
Defined in Arbiter.Core.Sql.Jobs | |
| Show FilterTable Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods showsPrec :: Int -> FilterTable -> ShowS# show :: FilterTable -> String# showList :: [FilterTable] -> ShowS# | |
data JobSortColumnSource #
Sortable columns on the main jobs table.
Constructors
| JsId | By |
| JsPriority | By |
| JsAttempts | By |
| JsInsertedAt | By |
| JsNotVisibleUntil | By |
| JsGroupKey | By |
| JsParentId | By |
| JsLastAttemptedAt | By |
Instances
| Eq JobSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods (==) :: JobSortColumn -> JobSortColumn -> Bool# (/=) :: JobSortColumn -> JobSortColumn -> Bool# | |
| Bounded JobSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs | |
| Enum JobSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods succ :: JobSortColumn -> JobSortColumn# pred :: JobSortColumn -> JobSortColumn# toEnum :: Int -> JobSortColumn# fromEnum :: JobSortColumn -> Int# enumFrom :: JobSortColumn -> [JobSortColumn]# enumFromThen :: JobSortColumn -> JobSortColumn -> [JobSortColumn]# enumFromTo :: JobSortColumn -> JobSortColumn -> [JobSortColumn]# enumFromThenTo :: JobSortColumn -> JobSortColumn -> JobSortColumn -> [JobSortColumn]# | |
| Show JobSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods showsPrec :: Int -> JobSortColumn -> ShowS# show :: JobSortColumn -> String# showList :: [JobSortColumn] -> ShowS# | |
jobSortColumnName :: JobSortColumn -> TextSource #
Underlying SQL column name for a JobSortColumn.
data DLQSortColumnSource #
Constructors
| DlqId | By |
| DlqFailedAt | By |
| DlqJobId | By |
| DlqPriority | By |
| DlqAttempts | By |
| DlqInsertedAt | By |
| DlqGroupKey | By |
| DlqParentId | By |
| DlqLastAttemptedAt | By |
Instances
| Eq DLQSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods (==) :: DLQSortColumn -> DLQSortColumn -> Bool# (/=) :: DLQSortColumn -> DLQSortColumn -> Bool# | |
| Bounded DLQSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs | |
| Enum DLQSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods succ :: DLQSortColumn -> DLQSortColumn# pred :: DLQSortColumn -> DLQSortColumn# toEnum :: Int -> DLQSortColumn# fromEnum :: DLQSortColumn -> Int# enumFrom :: DLQSortColumn -> [DLQSortColumn]# enumFromThen :: DLQSortColumn -> DLQSortColumn -> [DLQSortColumn]# enumFromTo :: DLQSortColumn -> DLQSortColumn -> [DLQSortColumn]# enumFromThenTo :: DLQSortColumn -> DLQSortColumn -> DLQSortColumn -> [DLQSortColumn]# | |
| Show DLQSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods showsPrec :: Int -> DLQSortColumn -> ShowS# show :: DLQSortColumn -> String# showList :: [DLQSortColumn] -> ShowS# | |
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 |
| ArchiveCompletedAt | By |
| ArchiveInsertedAt | By |
| ArchiveJobId | By |
| ArchiveAttempts | By |
| ArchiveGroupKey | By |
| ArchiveParentId | By |
Instances
| Eq ArchiveSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods (==) :: ArchiveSortColumn -> ArchiveSortColumn -> Bool# (/=) :: ArchiveSortColumn -> ArchiveSortColumn -> Bool# | |
| Bounded ArchiveSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs | |
| Enum ArchiveSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods succ :: ArchiveSortColumn -> ArchiveSortColumn# pred :: ArchiveSortColumn -> ArchiveSortColumn# toEnum :: Int -> ArchiveSortColumn# fromEnum :: ArchiveSortColumn -> Int# enumFrom :: ArchiveSortColumn -> [ArchiveSortColumn]# enumFromThen :: ArchiveSortColumn -> ArchiveSortColumn -> [ArchiveSortColumn]# enumFromTo :: ArchiveSortColumn -> ArchiveSortColumn -> [ArchiveSortColumn]# enumFromThenTo :: ArchiveSortColumn -> ArchiveSortColumn -> ArchiveSortColumn -> [ArchiveSortColumn]# | |
| Show ArchiveSortColumn Source # | |
Defined in Arbiter.Core.Sql.Jobs Methods showsPrec :: Int -> ArchiveSortColumn -> ShowS# show :: ArchiveSortColumn -> String# showList :: [ArchiveSortColumn] -> ShowS# | |
archiveSortColumnName :: ArchiveSortColumn -> TextSource #
The archive column a sort key names.
Sort direction.
Instances
| Eq SortDir Source # | |
| Bounded SortDir Source # | |
| Enum SortDir Source # | |
| Show SortDir Source # | |
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.
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.
insertJobsBatchSQL_ :: SchemaName -> TableName -> Query () -> Query ()Source #
insertJobsBatchSQL with no RETURNING.
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.