| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Core.CronSchedule
Description
Types and postgresql-simple operations for the cron_schedules table.
Since cron operations are administrative metadata (not part of job processing
transactions), they use postgresql-simple directly via a Connection
parameter -- no MonadArbiter needed.
The table stores both the code-defined defaults and user overrides separately.
On worker init, only the default_* columns are upserted -- user overrides
(override_*, enabled) are preserved.
Synopsis
- data CronScheduleRow = CronScheduleRow {}
- data CronScheduleUpdate = CronScheduleUpdate {}
- effectiveExpression :: CronScheduleRow -> Text
- effectiveOverlap :: CronScheduleRow -> Text
- upsertCronScheduleDefault :: Connection -> Text -> Text -> Text -> Text -> IO ()
- listCronSchedules :: Connection -> Text -> IO [CronScheduleRow]
- getCronScheduleByName :: Connection -> Text -> Text -> IO (Maybe CronScheduleRow)
- updateCronSchedule :: Connection -> Text -> Text -> CronScheduleUpdate -> IO Int64
- touchCronScheduleLastFired :: Connection -> Text -> Text -> IO ()
- deleteStaleSchedules :: Connection -> Text -> [Text] -> IO Int64
- touchCronSchedulesChecked :: Connection -> Text -> [Text] -> IO ()
- cronSchedulesTable :: Text -> Text
- createCronSchedulesTableSQL :: Text -> Text
Types
data CronScheduleRow Source #
A row from the cron_schedules table.
Constructors
| CronScheduleRow | |
Fields
| |
Instances
data CronScheduleUpdate Source #
Patch update for a cron schedule.
Each field uses Maybe (Maybe a):
Nothing= don't changeJust Nothing= reset to default (set column to NULL)Just (Just x)= set tox
Constructors
| CronScheduleUpdate | |
Instances
| FromJSON CronScheduleUpdate Source # | Manual instance to distinguish missing keys from
| ||||
Defined in Arbiter.Core.CronSchedule Methods parseJSON :: Value -> Parser CronScheduleUpdate parseJSONList :: Value -> Parser [CronScheduleUpdate] | |||||
| ToJSON CronScheduleUpdate Source # | |||||
Defined in Arbiter.Core.CronSchedule Methods toJSON :: CronScheduleUpdate -> Value toEncoding :: CronScheduleUpdate -> Encoding toJSONList :: [CronScheduleUpdate] -> Value toEncodingList :: [CronScheduleUpdate] -> Encoding omitField :: CronScheduleUpdate -> Bool | |||||
| Generic CronScheduleUpdate Source # | |||||
Defined in Arbiter.Core.CronSchedule Associated Types
Methods from :: CronScheduleUpdate -> Rep CronScheduleUpdate x # to :: Rep CronScheduleUpdate x -> CronScheduleUpdate # | |||||
| Show CronScheduleUpdate Source # | |||||
Defined in Arbiter.Core.CronSchedule Methods showsPrec :: Int -> CronScheduleUpdate -> ShowS # show :: CronScheduleUpdate -> String # showList :: [CronScheduleUpdate] -> ShowS # | |||||
| Eq CronScheduleUpdate Source # | |||||
Defined in Arbiter.Core.CronSchedule Methods (==) :: CronScheduleUpdate -> CronScheduleUpdate -> Bool # (/=) :: CronScheduleUpdate -> CronScheduleUpdate -> Bool # | |||||
| type Rep CronScheduleUpdate Source # | |||||
Defined in Arbiter.Core.CronSchedule type Rep CronScheduleUpdate = D1 ('MetaData "CronScheduleUpdate" "Arbiter.Core.CronSchedule" "arbiter-core-0.1.0.0-inplace" 'False) (C1 ('MetaCons "CronScheduleUpdate" 'PrefixI 'True) (S1 ('MetaSel ('Just "overrideExpression") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Maybe Text))) :*: (S1 ('MetaSel ('Just "overrideOverlap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (Maybe Text))) :*: S1 ('MetaSel ('Just "enabled") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Bool))))) | |||||
Effective values
effectiveExpression :: CronScheduleRow -> Text Source #
Effective expression: override if set, else default.
effectiveOverlap :: CronScheduleRow -> Text Source #
Effective overlap policy: override if set, else default.
Operations
upsertCronScheduleDefault :: Connection -> Text -> Text -> Text -> Text -> IO () Source #
Upsert a cron schedule's default values.
INSERT ON CONFLICT (name) DO UPDATE SET default_expression, default_overlap, updated_at. Does NOT touch override_expression, override_overlap, or enabled.
listCronSchedules :: Connection -> Text -> IO [CronScheduleRow] Source #
List all cron schedules.
getCronScheduleByName :: Connection -> Text -> Text -> IO (Maybe CronScheduleRow) Source #
Get a single cron schedule by name.
updateCronSchedule :: Connection -> Text -> Text -> CronScheduleUpdate -> IO Int64 Source #
Update a cron schedule (patch semantics).
Returns the number of rows affected (0 = not found, 1 = updated).
touchCronScheduleLastFired :: Connection -> Text -> Text -> IO () Source #
Update last_fired_at to NOW().
deleteStaleSchedules :: Connection -> Text -> [Text] -> IO Int64 Source #
Delete schedules whose names are not in the given list.
Returns the number of rows deleted. Does nothing if the list is empty.
touchCronSchedulesChecked :: Connection -> Text -> [Text] -> IO () Source #
Update last_checked_at to NOW() for the given schedule names.
SQL helpers
cronSchedulesTable :: Text -> Text Source #
Qualified table name for the cron_schedules table.
createCronSchedulesTableSQL :: Text -> Text Source #
DDL for the cron_schedules table.