APICronJob class
A route of the API called on a cron schedule by the APICronScheduler.
- The route is called with an internal system authentication (APIAuthentication.system) and the headers headerJob, headerScheduledAt, headerRun and headerAttempt.
- While the response has an
X-Continuationheader (APIResponse.continuation) the route is called again with the parametercontinuation, up to maxCalls calls per run. - Failed calls are retried by retry.
Constructors
-
APICronJob({required String name, required Object schedule, required String path, String? timeZone, APIRequestMethod method = APIRequestMethod.GET, Map<
String, dynamic> ? parameters, Object? payload, bool enabled = true, Duration timeout = const Duration(minutes: 5), int maxCalls = 100, Duration maxLateness = const Duration(days: 1), Duration leaseDuration = const Duration(minutes: 5), APICronRetry retry = APICronRetry.defaultRetry}) - APICronJob.fromConfig(String name, Map config, {APICronJob? base})
-
A job from
config(thecron.jobs.<name>config), overbaseif given. Without abase,scheduleandpathare required.factory
Properties
- enabled → bool
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- leaseDuration → Duration
-
The lease of the job lock, renewed while running: if the instance
running it stops, another instance takes the run over after it.
final
- location → Location
-
The location of timeZone, resolved on first use (loading the time
zones database only when needed: not while the routes are configured,
nor with the scheduler disabled). Throws an ArgumentError for an
unknown time zone (see validate).
latefinal
- maxCalls → int
-
The maximum calls of a run (continuations included).
final
- maxLateness → Duration
-
How late (after its scheduled time) an occurrence still runs: a missed
occurrence older than it is not run.
final
- method → APIRequestMethod
-
The route request method.
final
- name → String
-
The unique name of this job.
final
-
parameters
→ Map<
String, dynamic> -
final
- path → String
-
The route path (e.g.
/module/route).final - payload → Object?
-
final
- retry → APICronRetry
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schedule → CronExpression
-
final
- timeout → Duration
-
The expected maximum duration of a call: a slower call is logged (a
warning every timeout while it's still running). A route can't be
cancelled: the call is waited for (never retried or overlapped while
running), so the job never runs in parallel, and its result is used.
final
- timeZone → String?
-
The IANA time zone of the schedule (e.g.
Europe/Paris).null:UTC.final
Methods
-
nextAfter(
DateTime from) → TZDateTime? -
The next occurrence after
from. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
previousBefore(
DateTime to) → TZDateTime? -
The latest occurrence not after
to. -
toString(
) → String -
A string representation of this object.
override
-
validate(
) → void - Validates what is resolved lazily (location). Throws an ArgumentError if invalid.
-
withConfig(
Map? config) → APICronJob -
A copy of this job with
configapplied (thecron.jobs.<name>config):schedule,time_zone,method,path,parameters,enabled,timeout,max_calls,max_lateness,lease_duration,retryandattempts(over the attempts ofretry).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
isFullConfig(
Map config) → bool -
trueifconfig(acron.jobs.<name>config) defines a whole job (scheduleandpath), not only overrides of a job of the code.
Constants
- headerAttempt → const String
- headerJob → const String
- headerRun → const String
- headerScheduledAt → const String
- parameterContinuation → const String
- The parameter with the continuation token of the previous call.