APICron class
Schedules an API route method to be called by the APICronScheduler (see APICronJob).
With a cron expression (APICron.new) or by its fields (APICron.at):
@APICron('30 23 * * *', timeZone: 'Europe/Paris')
Future<APIResponse<int>> updateRates(APIRequest request) async { ... }
@APICron.at(minute: '30', hour: '23', timeZone: 'Europe/Paris')
Future<APIResponse<int>> updateRates2(APIRequest request) async { ... }
The job name defaults to <module>.<route> and can be overridden (or
disabled) by the cron.jobs.<name> config, which also overrides the
options of the annotation.
- Annotations
-
- @Target({TargetKind.method})
Constructors
-
APICron(String schedule, {String? name, String? timeZone, Map<
String, dynamic> ? parameters, bool enabled = true, int? maxCalls, int? attempts, Duration? timeout, Duration? maxLateness, Duration? leaseDuration, APICronRetry? retry}) -
A job on the cron expression
schedule(5 fields:minute hour day-of-month month day-of-week, or a macro like@daily).const -
APICron.at({String minute = '*', String hour = '*', String dayOfMonth = '*', String month = '*', String dayOfWeek = '*', String? name, String? timeZone, Map<
String, dynamic> ? parameters, bool enabled = true, int? maxCalls, int? attempts, Duration? timeout, Duration? maxLateness, Duration? leaseDuration, APICronRetry? retry}) -
A job on the schedule of the cron fields
minute,hour,dayOfMonth,monthanddayOfWeek(each a cron field:*, a value, a list, a range or a step; default*).const
Properties
- attempts → int?
-
The maximum attempts of each call (overrides the attempts of retry).
Default:
3.final - enabled → bool
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- jobRetry → APICronRetry
-
The retry policy of the job: retry, with attempts if given.
no setter
- leaseDuration → Duration?
-
See APICronJob.leaseDuration. Default: 5 minutes.
final
- maxCalls → int?
-
The maximum calls of a run. Default:
100.final - maxLateness → Duration?
-
See APICronJob.maxLateness. Default: 1 day.
final
- name → String?
-
The job name. Default:
<module>.<route>.final -
parameters
→ Map<
String, dynamic> ? -
final
- retry → APICronRetry?
-
The retry policy. Default: APICronRetry.defaultRetry.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schedule → String
-
The cron expression (see CronExpression).
final
- timeout → Duration?
-
See APICronJob.timeout. Default: 5 minutes.
final
- timeZone → String?
-
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJob(
String moduleName, String routeName, [APIRequestMethod? method]) → APICronJob -
The APICronJob of the route
routeNameof the modulemoduleName. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited