APICronScheduler class

Calls the routes of the APICronJobs of an APIRoot on their schedules.

Started by APIRoot when the config cron.enabled is true (see APICronConfig); one scheduler per process (not in the auxiliary workers).

Constructors

APICronScheduler(APIRoot apiRoot, Iterable<APICronJob> jobs, {APICronStore? store, Duration checkInterval = const Duration(seconds: 30), int historyDays = 90, String? owner, DateTime clock()?, Future<void> sleep(Duration delay)?})

Properties

apiRoot → APIRoot
final
checkInterval → Duration
How often the due jobs are checked.
final
hashCode → int
The hash code for this object.
no setterinherited
historyDays → int
The days the run history is kept (0: forever).
final
isStarted → bool
no setter
jobs → Map<String, APICronJob>
The jobs, by name.
no setter
owner → String
The ID of this scheduler instance (the owner of its runs and locks).
final
runningJobs → Set<String>
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
store → APICronStore
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
runNow(String name) → Future<APICronJobRun?>
Runs the job name now (an occurrence at the current time), with the same lock and claim of a scheduled run. null if already running, locked by another instance or this scheduler is stopped (stop). Throws an ArgumentError for an unknown job.
selectRuns(String name, {int limit = 20}) → FutureOr<List<APICronJobRun>>
The latest runs of the job name.
start() → void
Starts the periodic checks (and checks once now).
stop() → void
Stops the periodic checks. A running job stops after its current call (not cancelled): its run is left running and its lock released, so another instance resumes it from its continuation. See waitRunning.
tick() → Future<List<APICronJobRun>>
Checks the due jobs and runs them. Completes when the runs started by this check finish (with their runs).
toString() → String
A string representation of this object.
override
waitRunning() → Future<void>
Waits for the jobs running in this instance (e.g. after stop).

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

mergeJobs(Iterable<Iterable<APICronJob>> sources, Map<String, Map> config) → List<APICronJob>
Merges the jobs of sources (by name: a later job replaces an earlier one) and applies config (the cron.jobs config): a config entry overrides the job of its name, or adds a new job (with schedule and path).

Constants

maxSkippedRecords → const int
The maximum missed occurrences recorded as skipped per check.