Constructor
new AgendaUnit(directory)
Initialize the class. Resolves and stores the directory containing the job definition files.
Name | Type | Default | Description |
---|---|---|---|
directory |
string | ./app/jobs | Directory containing the job definition files. |
- Source:
Extends
Members
(static) name
Get the name of this service: 'jobs'
- Source:
(static) services
Define the services required by this unit.
- Source:
(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.
- boolean
- Source:
(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.
- Source:
(private) _di_deferred_services :Array.<string>
List of services that were deferred and not provided at the time of injection.
- Array.<string>
- Source:
canonical_item :string
Name of the unit's canonical item - 'job'
- string
- Source:
canonical_items :object
Mapping of canonical names to instances for this item.
- object
- Source:
directory :Promise.<void>|Promise.<string>
The root directory for this canonical resource's files.
- Promise.<void> | Promise.<string>
- Source:
suffix :string
File suffix for the unit's files - '.job.js'
- string
- Source:
Methods
(async) cleanup(app) → {Promise.<void>}
Clean up the resources managed by this unit. Stops the scheduler.
Name | Type | Description |
---|---|---|
app |
module:libflitter/app/FlitterApp~FlitterApp | the Flitter app |
- Source:
- Type
- Promise.<void>
directories() → {object}
Get the directories provided by this unit.
- Type
- object
get(name) → {object}
Resolve an unqualified canonical name to a registered canonical item.
Name | Type | Description |
---|---|---|
name |
string |
- Type
- object
(async) go(app) → {Promise.<void>}
Initialize the jobs service. Creates a new Agenda scheduler and registers the jobs in the canonical directory for this unit.
Name | Type | Description |
---|---|---|
app |
module:libflitter/app/FlitterApp~FlitterApp | the Flitter app |
- Source:
- Type
- Promise.<void>
(async) init_canonical_file(app, name, instance) → {Promise.<module:flitter-agenda/Job~Job>}
Initialize a single canonical file loaded by the unit. Defines a job in the scheduler using the exec method on the job's class definition.
Name | Type | Description |
---|---|---|
app |
module:libflitter/app/FlitterApp~FlitterApp | the Flitter app |
name |
string | the unqualified canonical name of the file |
instance |
module:flitter-agenda/Job~Job | include from the file; should be a class definition of the Job |
- Source:
- Type
- Promise.<module:flitter-agenda/Job~Job>
name() → {String}
Get the name of the unit. Should be a lowercase, alphanum/dash/underscore string.
- Source:
- Type
- String
status(setopt) → {string}
Get or set the unit's current status.
Name | Type | Attributes | Description |
---|---|---|---|
set |
string |
<optional> |
if provided, set the status of the unit |
- Source:
- current status of the unit
- Type
- string
templates() → {object}
Returns the templates managed by the AgendaUnit. Provides the 'job' template.
- Source:
- Type
- object