Options
All
  • Public
  • Public/Protected
  • All
Menu

Module task

Index

Functions

addMiddleware

allDelayed

  • allDelayed(): Promise<any>
  • 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 Promise<any>

allWorkingOn

  • allWorkingOn(): Promise<object>
  • Return all workers and what job they might be working on. Will throw an error if redis cannot be reached.

    Returns Promise<object>

cleanOldWorkers

  • cleanOldWorkers(age: number): Promise<object>
  • 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

    • age: number

    Returns Promise<object>

del

  • del(q: string, taskName: string, args?: object, count?: number): Promise<number>
  • Delete a previously enqueued task, which hasn't been run yet, from a queue. Will throw an error if redis cannot be reached.

    Inputs:

    • q: Which queue/priority is the task stored on?
    • taskName: The name of the job, likley to be the same name as a tak.
    • args: 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 api.tasks.queued or similar method.
    • count: Of the jobs that match q, taskName, and args, up to what position should we delete? (Default 0; this command is 0-indexed)

    Parameters

    • q: string
    • taskName: string
    • Optional args: object
      • [key: string]: any
    • Optional count: number

    Returns Promise<number>

delDelayed

  • delDelayed(q: string, taskName: string, args?: object): Promise<any[]>
  • Delete all previously enqueued tasks, which haven't been run yet, from all possible delayed timestamps. Will throw an error if redis cannot be reached.

    Inputs:

    • q: Which queue/priority is to run on?
    • taskName: The name of the job, likley to be the same name as a tak.
    • args 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 api.tasks.delayedAt or similar method.

    Parameters

    • q: string
    • taskName: string
    • Optional args: object
      • [key: string]: any

    Returns Promise<any[]>

delLock

  • delLock(lock: string): Promise<number>
  • 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

    • lock: string

    Returns Promise<number>

delQueue

  • delQueue(q: string): Promise<void>
  • Delete a queue in redis, and all jobs stored on it. Will throw an error if redis cannot be reached.

    Parameters

    • q: string

    Returns Promise<void>

delayedAt

  • delayedAt(timestamp: number): Promise<any>
  • Return all jobs which have been enqueued to run at a certain timestamp. Will throw an error if redis cannot be reached.

    Parameters

    • timestamp: number

    Returns Promise<any>

details

  • details(): Promise<object>
  • Return wholistic details about the task system, including failures, queues, and workers. Will throw an error if redis cannot be reached.

    Returns Promise<object>

enqueue

  • enqueue(taskName: string, params: object, queue?: string): Promise<any>
  • Enqueue a task to be performed in the background. Will throw an error if redis cannot be reached.

    Parameters

    • taskName: string
    • params: object
      • [key: string]: any
    • Default value queue: string = api.tasks.tasks[taskName].queue

    Returns Promise<any>

enqueueAllRecurrentTasks

  • enqueueAllRecurrentTasks(): Promise<any[]>
  • 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 Promise<any[]>

enqueueAt

  • enqueueAt(timestamp: number, taskName: string, params: object, queue?: string): Promise<void>
  • 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.

    Inputs:

    • taskName: The name of the task.
    • params: Params to pass to the task.
    • queue: (Optional) Which queue/priority to run this instance of the task on.

    Parameters

    • timestamp: number
    • taskName: string
    • params: object
      • [key: string]: any
    • Default value queue: string = api.tasks.tasks[taskName].queue

    Returns Promise<void>

enqueueIn

  • enqueueIn(time: number, taskName: string, params: object, queue?: string): Promise<void>
  • 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.

    Inputs:

    • timestamp: 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: The name of the task.
    • params: Params to pass to the task.
    • queue: (Optional) Which queue/priority to run this instance of the task on.

    Parameters

    • time: number
    • taskName: string
    • params: object
      • [key: string]: any
    • Default value queue: string = api.tasks.tasks[taskName].queue

    Returns Promise<void>

enqueueRecurrentTask

  • enqueueRecurrentTask(taskName: string): Promise<void>
  • 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

    • taskName: string

    Returns Promise<void>

failed

  • failed(start: number, stop: number): Promise<Array<object>>
  • Retrieve the details of failed jobs between start and stop (0-indexed). Will throw an error if redis cannot be reached.

    Parameters

    • start: number
    • stop: number

    Returns Promise<Array<object>>

failedCount

  • failedCount(): Promise<number>
  • How many jobs are in the failed queue. Will throw an error if redis cannot be reached.

    Returns Promise<number>

locks

  • locks(): Promise<Object>
  • 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 Promise<Object>

queued

  • queued(q: string, start: number, stop: number): Promise<Array<object>>
  • 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.

    Inputs:

    • q The name of the queue.
    • start The index of the first job to return.
    • stop The index of the last job to return.

    Parameters

    • q: string
    • start: number
    • stop: number

    Returns Promise<Array<object>>

removeFailed

  • removeFailed(failedJob: any): Promise<number>
  • Remove a specific job from the failed queue. Will throw an error if redis cannot be reached.

    Parameters

    • failedJob: any

    Returns Promise<number>

retryAndRemoveFailed

  • retryAndRemoveFailed(failedJob: any): Promise<any>
  • 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

    • failedJob: any

    Returns Promise<any>

scheduledAt

  • scheduledAt(q: string, taskName: string, args: object): Promise<Array<number>>
  • Return the timestamps a task is scheduled for. Will throw an error if redis cannot be reached.

    Inputs:

    • q: Which queue/priority is to run on?
    • taskName: The name of the job, likley to be the same name as a tak.
    • args: 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 api.tasks.delayedAt or similar method.

    Parameters

    • q: string
    • taskName: string
    • args: object
      • [key: string]: any

    Returns Promise<Array<number>>

stats

  • stats(): Promise<__type>
  • Return all resque stats for this namespace (how jobs failed, jobs succeded, etc) Will throw an error if redis cannot be reached.

    Returns Promise<__type>

stopRecurrentTask

  • stopRecurrentTask(taskName: string): Promise<number>
  • Stop a task with a frequency by removing it from all possible queues. Will throw an error if redis cannot be reached.

    Parameters

    • taskName: string

    Returns Promise<number>

timestamps

  • timestamps(): Promise<Array<number>>
  • 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 Promise<Array<number>>

workers

  • workers(): Promise<Object>
  • 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 Promise<Object>

workingOn

  • workingOn(workerName: string, queues: string): Promise<any>
  • 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

    • workerName: string
    • queues: string

    Returns Promise<any>

Generated using TypeDoc