Cron scheduler: evaluates crontab entries and enqueues jobs when due.
Cron state (last_execution) is persisted to known_crontabs so that the scheduler survives process restarts without double-firing. Jobs are enqueued with job_key_mode = unsafe_dedupe, so multiple scheduler instances running in parallel will not produce duplicate queue entries.
The background polling thread evaluates all registered entries on each tick and fires any whose next_run_at <= now. The poll interval is coarse (default 10 s) because cron granularity is one minute.
Relies on the ReadableColumn protocol extensions defined in database.core to return java.time.Instant values for TIMESTAMPTZ columns.
Cron scheduler: evaluates crontab entries and enqueues jobs when due. Cron state (last_execution) is persisted to known_crontabs so that the scheduler survives process restarts without double-firing. Jobs are enqueued with job_key_mode = unsafe_dedupe, so multiple scheduler instances running in parallel will not produce duplicate queue entries. The background polling thread evaluates all registered entries on each tick and fires any whose next_run_at <= now. The poll interval is coarse (default 10 s) because cron granularity is one minute. Relies on the ReadableColumn protocol extensions defined in database.core to return java.time.Instant values for TIMESTAMPTZ columns.
(create-scheduler job-system crontabs emitter)(create-scheduler job-system crontabs emitter config)Creates a cron scheduler. Call start! to begin processing. job-system is {:pool datasource :validator validator}. crontabs is a vector of CrontabEntry maps. emitter is a monitoring/Emitter. config keys: :poll-interval-ms, :timezone.
Creates a cron scheduler. Call start! to begin processing.
job-system is {:pool datasource :validator validator}.
crontabs is a vector of CrontabEntry maps.
emitter is a monitoring/Emitter.
config keys: :poll-interval-ms, :timezone.(cron-next schedule base-time timezone)Returns the next Instant a cron schedule fires after base-time in timezone. Returns nil if the expression has no future occurrence.
Returns the next Instant a cron schedule fires after base-time in timezone. Returns nil if the expression has no future occurrence.
(cron-next-public schedule base-time timezone)Returns the next Instant a cron schedule fires after base-time in timezone. Returns nil if the expression has no future occurrence.
Returns the next Instant a cron schedule fires after base-time in timezone. Returns nil if the expression has no future occurrence.
(fire-due-jobs! scheduler)Evaluates all crontab entries and fires any whose next_run_at <= now. Returns a map with :fired (enqueued count) and :skipped (not-due count).
Evaluates all crontab entries and fires any whose next_run_at <= now. Returns a map with :fired (enqueued count) and :skipped (not-due count).
(running? scheduler)Returns true if the polling loop is active.
Returns true if the polling loop is active.
(start! scheduler)Upserts crontab records then starts the polling loop. Throws if already running. Returns scheduler.
Upserts crontab records then starts the polling loop. Throws if already running. Returns scheduler.
(stats scheduler)Returns a snapshot of scheduler operational metrics. Keys: :fired, :errors.
Returns a snapshot of scheduler operational metrics. Keys: :fired, :errors.
(stop! scheduler)(stop! scheduler timeout-ms)Signals the polling loop to stop, interrupts the thread, and joins it. Returns scheduler.
Signals the polling loop to stop, interrupts the thread, and joins it. Returns scheduler.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |