Job

flitter-agenda/Job~ Job

Parent class to all flitter-agenda job definitions. Specifies the method that should be executed when the job is run.


Constructor

new Job()

Extends

Members

(static) services

Get the services required by this class. The 'jobs' service is requested automatically.

(private) _di_allow_defer :boolean

If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.

Type:
  • boolean

(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>

Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.

(private) _di_deferred_services :Array.<string>

List of services that were deferred and not provided at the time of injection.

Type:
  • Array.<string>

JOB_NAME :string

Set by the AgendaUnit when the job is loaded. The Flitter canonical name of the job. This is used to identify the job class to the Agenda scheduler.

Type:
  • string

Methods

(async, static) enqueue(whenopt, dataopt) → {Promise.<void>}

Queue a request to run this job at the specific time with the data.

Parameters:
Name Type Attributes Default Description
when string <optional>
'now'

a time describing string - 'in 3 minutes'/'now'/'tomorrow'

data object <optional>
{}

optional data to be passed to the job

Returns:
Type
Promise.<void>

exec(job, done)

Executed when the job is run. See the Agenda package docs for more info.

Parameters:
Name Type Description
job Job

Agenda job instance. See the Agenda package docs for more info.

done function

should be called when the job completes