arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.Cron

Description

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

Cron SQL templates.

Synopsis

Documentation

upsertCronDefaultSQL :: SchemaName -> Text -> Text -> Text -> Text -> Maybe Text -> Bool -> Query ()Source #

Upsert a cron schedule's default values, preserving override_* columns on conflict. An unchanged schedule is left alone. initialEnabled applies only to a row this statement creates. An existing row keeps the enabled state it already has.

listCronSchedulesSQL :: SchemaName -> Maybe Text -> Query CronScheduleRowSource #

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

getCronScheduleByNameSQL :: SchemaName -> Text -> Query CronScheduleRowSource #

Get a single cron schedule by name.

updateCronScheduleSQL :: SchemaName -> Text -> CronScheduleUpdate -> Maybe (Query ())Source #

Patch a cron schedule's overrides and enabled flag. Nothing when the patch sets no column. Just Nothing clears an override. Disabling also drops a pending run request.

touchCronCheckedSQL :: SchemaName -> [Text] -> UTCTime -> Query ()Source #

Set last_checked_at to the caller-supplied watermark for the given schedule names. The watermark is the minute boundary the scheduler finished evaluating. GREATEST keeps it from moving backward.

tryFireCronGateSQL :: SchemaName -> Text -> UTCTime -> Query ()Source #

Fire-once-per-minute gate. Advances last_fired_at to the minute floor when the existing value is less. Zero rows means another pool won.

tryAcquireCronLeaderSQL :: SchemaName -> Text -> Text -> Query BoolSource #

Per-(schema, queue, name) transaction-scoped advisory lock for cron.

requestCronRunSQL :: SchemaName -> Text -> Query TextSource #

Stamp a run request on an enabled schedule and NOTIFY. Returns stamped, pending, disabled or not_found.

claimCronRunSQL :: SchemaName -> Text -> Query CronScheduleRowSource #

Claim a pending run request, clearing the flag and returning the claimed row.

touchCronManualRunSQL :: SchemaName -> Text -> UTCTime -> Query ()Source #

Record when a manual run last fired a job.

pendingCronRunsSQL :: SchemaName -> [Text] -> Query TextSource #

Names of enabled schedules with a pending run request among the given names.