- Source:
Properties:
| Name | Type | Description |
|---|---|---|
tasks |
Object | The tasks defined on this server. |
jobs |
Object | The tasks defined on this server, converted into Node Resque jobs. |
middleware |
Object | Available Task Middleware. |
globalMiddleware |
Array | Array of global middleware modules. |
Tools for enquing and inspecting the task sytem (delayed jobs).
Extends
Methods
(async, static) allDelayed() → {Promise.<Object>}
- Source:
Retrun all delayed jobs, orginized by the timetsamp at where they are to run at. Note: This is a very slow command. Will throw an error if redis cannot be reached.
Returns:
- Type
- Promise.<Object>
(async, static) allWorkingOn() → {Promise.<Object>}
- Source:
Return all workers and what job they might be working on. Will throw an error if redis cannot be reached.
Returns:
An Object, with worker names as keys, containing the job they are working on. If the worker is idle, 'started' will be returned.
- Type
- Promise.<Object>
(async, static) cleanOldWorkers(age) → {Promise.<ObjecT>}
- Source:
If a worker process crashes, it will leave its state in redis as "working". You can remove workers from redis you know to be over, by specificing an age which would make them too old to exist. This method will remove the data created by a 'stuck' worker and move the payload to the error queue. However, it will not actually remove any processes which may be running. A job may be running that you have removed. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
age |
Number | The age of workers you know to be over, in seconds. |
Returns:
Details about workers which were removed.
- Type
- Promise.<ObjecT>
(static) del(q, taskName, args, count) → {Promise}
- Source:
Delete a previously enqueued task, which hasn't been run yet, from a queue. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
q |
string | Which queue/priority is the task stored on? |
taskName |
string | The name of the job, likley to be the same name as a tak. |
args |
Object | Array | The arguments of the job. Note, arguments passed to a Task initially may be modified when enqueuing.
It is best to read job properties first via |
count |
Number | Of the jobs that match q, taskName, and args, up to what position should we delete? (Default 0; this command is 0-indexed) |
Returns:
- Type
- Promise
(async, static) delayedAt(timestamp) → {Promise.<Array>}
- Source:
Return all jobs which have been enqueued to run at a certain timestamp. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
timestamp |
Number | The timestamp to return jobs from. Note: timestamp will be a unix timestamp, not javascript MS timestamp. |
Returns:
An array of jobs.
- Type
- Promise.<Array>
(static) delDelayed(q, taskName, args) → {Promise}
- Source:
Delete all previously enqueued tasks, which hasn't been run yet, from all possible delayed timestamps. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
q |
string | Which queue/priority is to run on? |
taskName |
string | The name of the job, likley to be the same name as a tak. |
args |
Object | Array | The arguments of the job. Note, arguments passed to a Task initially may be modified when enqueuing.
It is best to read job properties first via |
Returns:
- Type
- Promise
(async, static) delLock(lock) → {Promise}
- Source:
- See:
Delete a lock on a job or worker. Locks can be found via api.tasks.locks
Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
lock |
string | The name of the lock. |
Returns:
- Type
- Promise
(async, static) delQueue(q) → {Promise}
- Source:
Delete a queue in redis, and all jobs stored on it. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
q |
string | The name of the queue. |
Returns:
- Type
- Promise
(async, static) details() → {Promise}
- Source:
Reurn wholistic details about the whole task system, including failures, queues, and workers. Will throw an error if redis cannot be reached.
Returns:
[description]
- Type
- Promise
(async, static) enqueue(taskName, params, queue) → {Promise.<Boolean>}
- Source:
Enqueue a task to be performed in the background. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
taskName |
String | The name of the task. |
params |
Object | Params to pass to the task. |
queue |
string | (Optional) Which queue/priority to run this instance of the task on. |
Returns:
Did the task enqueue?
- Type
- Promise.<Boolean>
(async, static) enqueueAllRecurrentTasks() → {Promise}
- Source:
- See:
This is run automatically at boot for all tasks which have a frequency, calling api.tasks.enqueueRecurrentTask
Will throw an error if redis cannot be reached.
Returns:
- Type
- Promise
(static) enqueueAt(timestamp, taskName, params, queue) → {Promise}
- Source:
Enqueue a task to be performed in the background, at a certain time in the future. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
timestamp |
Number | At what time the task is able to be run. Does not gaurentee that the task will be run at this time. (in ms) |
taskName |
String | The name of the task. |
params |
Object | Params to pass to the task. |
queue |
string | (Optional) Which queue/priority to run this instance of the task on. |
Returns:
- Type
- Promise
(static) enqueueIn(time, taskName, params, queue) → {Promise}
- Source:
Enqueue a task to be performed in the background, at a certain number of ms from now. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
time |
Number | How long from now should we wait until it is OK to run this task? (in ms) |
taskName |
String | The name of the task. |
params |
Object | Params to pass to the task. |
queue |
string | (Optional) Which queue/priority to run this instance of the task on. |
Returns:
- Type
- Promise
(async, static) enqueueRecurrentTask(taskName) → {Promise}
- Source:
- See:
Ensures that a task which has a frequency is either running, or already enqueued.
This is run automatically at boot for all tasks which have a frequency, via api.tasks.enqueueAllRecurrentTasks.
Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
taskName |
string | The name of the task. |
Returns:
- Type
- Promise
(async, static) failed(start, stop) → {Promise.<Array>}
- Source:
Retrieve the details of failed jobs between start and stop (0-indexed). Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
start |
Number | The index of the first job to return. |
stop |
Number | The index of the last job to return. |
Returns:
An array of the failed jobs.
- Type
- Promise.<Array>
(async, static) failedCount() → {Promise.<Number>}
- Source:
How many jobs are in the failed queue. Will throw an error if redis cannot be reached.
Returns:
The number of failed jobs at this moment.
- Type
- Promise.<Number>
(async, static) locks() → {Promise|Object}
- Source:
Return any locks, as created by resque plugins or task middleware, in this redis namespace.
Will contain locks with keys like resque:lock:{job} and resque:workerslock:{workerId}
Will throw an error if redis cannot be reached.
Returns:
Locks, orginzed by type.
- Type
- Promise | Object
(async, static) queued(q, start, stop) → {Promise.<Array>}
- Source:
Retrieve the details of jobs enqueued on a certain queue between start and stop (0-indexed) Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
q |
string | The name of the queue. |
start |
Number | The index of the first job to return. |
stop |
Number | The index of the last job to return. |
Returns:
An array of the jobs enqueued.
- Type
- Promise.<Array>
(async, static) removeFailed(failedJob) → {Promise}
- Source:
- See:
Remove a specific job from the failed queue. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
failedJob |
Object | The failed job, as defined by |
Returns:
- Type
- Promise
(async, static) retryAndRemoveFailed(failedJob) → {Promise}
- Source:
- See:
Remove a specific job from the failed queue, and retry it by placing it back into its original queue. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
failedJob |
Object | The failed job, as defined by |
Returns:
- Type
- Promise
(async, static) scheduledAt(q, taskName, args) → {Promise.<Arra>}
- Source:
Return the timestamps a task is scheduled for. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
q |
string | Which queue/priority is to run on? |
taskName |
string | The name of the job, likley to be the same name as a tak. |
args |
Object | Array | The arguments of the job. Note, arguments passed to a Task initially may be modified when enqueuing.
It is best to read job properties first via |
Returns:
Returns an array of timestamps.
- Type
- Promise.<Arra>
(async, static) stats() → {Promise.<Object>}
- Source:
Return all resque stats for this namespace (how jobs failed, jobs succeded, etc) Will throw an error if redis cannot be reached.
Returns:
(varies on your redis instance)
- Type
- Promise.<Object>
(async, static) stopRecurrentTask(taskName) → {Promise.<Number>}
- Source:
Stop a task with a frequency by removing it from all possible queues. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
taskName |
string | The name of the task. |
Returns:
How many tasks were removed.
- Type
- Promise.<Number>
(async, static) timestamps() → {Promise.<Array>}
- Source:
- See:
List all timestamps for which tasks are enqueued in the future, via api.tasks.enqueueIn or api.tasks.enqueueAt
Will throw an error if redis cannot be reached.
Returns:
An array of timetamps. Note: These timestamps will be in unix timestamps, not javascript MS timestamps.
- Type
- Promise.<Array>
(async, static) workers() → {Promise.<Object>}
- Source:
Retrun all workers registered by all members of this cluster. Note: MultiWorker processors each register as a unique worker. Will throw an error if redis cannot be reached.
Returns:
- Type
- Promise.<Object>
(async, static) workingOn(workerName, queues) → {Promise.<Object>}
- Source:
What is a given worker working on? If the worker is idle, 'started' will be returned. Will throw an error if redis cannot be reached.
Parameters:
| Name | Type | Description |
|---|---|---|
workerName |
string | The worker base name, usually a function of the PID. |
queues |
string | The queues the worker is assigned to work. |
Returns:
- Type
- Promise.<Object>