Class Queue<DataType, ReturnType, NameType>

Type Parameters

  • DataType = any

  • ReturnType = any

  • NameType extends string = string

Hierarchy

  • Queue<DataType, ReturnType, NameType>
    • Queue

Constructors

  • Type Parameters

    • DataType = any

    • ReturnType = any

    • NameType extends string = string

    Parameters

    Returns Queue<DataType, ReturnType, NameType>

Properties

closing: Promise<void>
jobsOpts: BaseJobOptions
keys: KeysMap
name: string
opts: QueueBaseOptions
toKey: ((type) => string)

Type declaration

    • (type): string
    • Parameters

      • type: string

      Returns string

token: string

Accessors

  • get client(): Promise<RedisClient>
  • Returns a promise that resolves to a redis client. Normally used only by subclasses.

    Returns Promise<RedisClient>

  • get defaultJobOptions(): JobsOptions
  • Returns this instance current default job options.

    Returns JobsOptions

  • get redisVersion(): string
  • Returns the version of the Redis instance the client is connected to,

    Returns string

  • get repeat(): Promise<Repeat>
  • Returns Promise<Repeat>

Methods

  • Adds a Job to the queue.

    Parameters

    Returns Promise<Job<DataType, ReturnType, NameType>>

  • Adds an array of jobs to the queue. This method may be faster than adding one job at a time in a sequence.

    Parameters

    • jobs: {
          data: DataType;
          name: NameType;
          opts?: BulkJobProOptions;
      }[]

      The array of jobs to add to the queue. Each job is defined by 3 properties, 'name', 'data' and 'opts'. They follow the same signature as 'Queue.add'.

    Returns Promise<Job<DataType, ReturnType, NameType>[]>

  • Cleans jobs from a queue. Similar to drain but keeps jobs within a certain grace period.

    Parameters

    • grace: number

      The grace period

    • limit: number

      Max number of jobs to clean

    • Optional type: "completed" | "failed" | "wait" | "active" | "delayed" | "paused"

      The type of job to clean Possible values are completed, wait, active, paused, delayed, failed. Defaults to completed.

    Returns Promise<string[]>

    Id jobs from the deleted records

  • Close the queue instance.

    Returns Promise<void>

  • Returns the number of jobs waiting to be processed. This includes jobs that are "waiting" or "delayed".

    Returns Promise<number>

  • Cleans all the jobs that are part of a group.

    Parameters

    • groupId: string | number

    Returns Promise<void>

  • Cleans all the groups in this queue

    Returns Promise<void>

  • Force disconnects a connection.

    Returns Promise<void>

  • Drains the queue, i.e., removes all jobs that are waiting or delayed, but not active, completed or failed.

    Parameters

    • Optional delayed: boolean

      Pass true if it should also clean the delayed jobs.

    Returns Promise<void>

  • Type Parameters

    • U extends keyof QueueListener<DataType, ResultType, NameType>

    Parameters

    • event: U
    • Rest ...args: Parameters<QueueListener<DataType, ReturnType, NameType>[U]>

    Returns boolean

  • Returns the jobs that are in the "active" status.

    Parameters

    • Optional start: number

      zero based index from where to start returning jobs.

    • Optional end: number

      zero based index where to stop returning jobs.

    Returns Promise<Job<DataType, ReturnType, NameType>[]>

  • Returns the number of jobs in active status.

    Returns Promise<number>

  • Returns the jobs that are in the "completed" status.

    Parameters

    • Optional start: number

      zero based index from where to start returning jobs.

    • Optional end: number

      zero based index where to stop returning jobs.

    Returns Promise<Job<DataType, ReturnType, NameType>[]>

  • Returns the number of jobs in completed status.

    Returns Promise<number>

  • Returns the jobs that are in the "delayed" status.

    Parameters

    • Optional start: number

      zero based index from where to start returning jobs.

    • Optional end: number

      zero based index where to stop returning jobs.

    Returns Promise<Job<DataType, ReturnType, NameType>[]>

  • Returns the number of jobs in delayed status.

    Returns Promise<number>

  • Returns the jobs that are in the "failed" status.

    Parameters

    • Optional start: number

      zero based index from where to start returning jobs.

    • Optional end: number

      zero based index where to stop returning jobs.

    Returns Promise<Job<DataType, ReturnType, NameType>[]>

  • Returns the number of jobs in failed status.

    Returns Promise<number>

  • Get jobs that are part of a given group.

    Parameters

    • groupId: string | number
    • start: number = 0
    • end: number = -1

    Returns Promise<Job<DataType, ReturnType, NameType>[]>

  • Gets the count of jobs inside a given group id.

    Parameters

    • groupId: string | number

    Returns Promise<number>

  • Get the given group status.

    Parameters

    • groupId: string

      The group id to get the status for.

    Returns Promise<GroupStatus>

    GroupStatus - The status of the group or null if the group does not exist.

  • Get the group ids with jobs current jobs in them.

    TODO: Support group id filtering.

    Parameters

    • start: number = 0
    • end: number = -1

    Returns Promise<{
        id: string;
        status: GroupStatus;
    }[]>

  • Gets all the groups that are in a particular status.

    Parameters

    • status: GroupStatus

      GroupStatus so we can filter by status

    • start: number = 0

      start index, used for pagination.

    • end: number = -1

      end index, used for pagination.

    Returns Promise<{
        count: number;
        id: string;
    }[]>

    an array of objects with the group id and status.

  • Get the total number of groups with jobs in them.

    Returns Promise<number>

  • Get the total number of groups with jobs in them, in their different statuses.

    Returns Promise<{
        limited: number;
        maxed: number;
        paused: number;
        waiting: number;
    }>

  • Gets the count of all the jobs belonging to any group.

    Returns Promise<number>

  • Parameters

    • jobId: string

    Returns Promise<Job<DataType, ReturnType, NameType>>

  • Job counts by type

    Queue#getJobCountByTypes('completed') => completed count Queue#getJobCountByTypes('completed,failed') => completed + failed count Queue#getJobCountByTypes('completed', 'failed') => completed + failed count Queue#getJobCountByTypes('completed', 'waiting', 'failed') => completed + waiting + failed count

    Parameters

    Returns Promise<number>

  • Returns the job counts for each type specified or every list/set in the queue by default.

    Parameters

    Returns Promise<{
        [index: string]: number;
    }>

    An object, key (type) and value (count)

  • Returns the logs for a given Job.

    Parameters

    • jobId: string

      the id of the job to get the logs for.

    • Optional start: number

      zero based index from where to start returning jobs.

    • Optional end: number

      zero based index where to stop returning jobs.

    • Optional asc: boolean

      if true, the jobs will be returned in ascending order.

    Returns Promise<{
        count: number;
        logs: string[];
    }>

  • Get current job state.

    Parameters

    • jobId: string

    Returns Promise<"unknown" | JobState>

    Returns one of these values: 'completed', 'failed', 'delayed', 'active', 'waiting', 'waiting-children', 'unknown'.

  • Returns the jobs that are on the given statuses (note that JobType is synonym for job status)

    Parameters

    • Optional types: JobType | JobType[]

      the statuses of the jobs to return.

    • Optional start: number

      zero based index from where to start returning jobs.

    • Optional end: number

      zero based index where to stop returning jobs.

    • Optional asc: boolean

      if true, the jobs will be returned in ascending order.

    Returns Promise<Job<DataType, ReturnType, NameType>[]>

  • Get queue metrics related to the queue.

    This method returns the gathered metrics for the queue. The metrics are represented as an array of job counts per unit of time (1 minute).

    Parameters

    • type: "completed" | "failed"
    • Optional start: number

      Start point of the metrics, where 0 is the newest point to be returned.

    • Optional end: number

      End point of the metrics, where -1 is the oldest point to be returned.

    Returns Promise<Metrics>

    • Returns an object with queue metrics.
  • Get queue events list related to the queue. Note: GCP does not support SETNAME, so this call will not work

    Returns Promise<{
        [index: string]: string;
    }[]>

    • Returns an array with queue events info.
  • Parameters

    • types: JobType[]
    • Optional start: number
    • Optional end: number
    • Optional asc: boolean

    Returns Promise<string[]>

  • Get all repeatable meta jobs.

    Parameters

    • Optional start: number

      Offset of first job to return.

    • Optional end: number

      Offset of last job to return.

    • Optional asc: boolean

      Determine the order in which jobs are returned based on their next execution time.

    Returns Promise<{
        endDate: number;
        id: string;
        key: string;
        name: string;
        next: number;
        pattern: string;
        tz: string;
    }[]>

  • Get library version.

    Returns Promise<string>

    the content of the meta.library field.

  • Returns the jobs that are in the "waiting" status.

    Parameters

    • Optional start: number

      zero based index from where to start returning jobs.

    • Optional end: number

      zero based index where to stop returning jobs.

    Returns Promise<Job<DataType, ReturnType, NameType>[]>

  • Returns the jobs that are in the "waiting" status.

    Parameters

    • Optional start: number

      zero based index from where to start returning jobs.

    • Optional end: number

      zero based index where to stop returning jobs.

    Returns Promise<Job<DataType, ReturnType, NameType>[]>

  • Returns the number of jobs in waiting-children status.

    Returns Promise<number>

  • Returns the number of jobs in waiting or paused statuses.

    Returns Promise<number>

  • Get the worker list related to the queue. i.e. all the known workers that are available to process jobs for this queue. Note: GCP does not support SETNAME, so this call will not work

    Returns Promise<{
        [index: string]: string;
    }[]>

    • Returns an array with workers info.
  • Returns true if the queue is currently paused.

    Returns Promise<boolean>

  • Parameters

    • Optional opts: {
          count?: number;
          force?: boolean;
      }
      • Optional count?: number
      • Optional force?: boolean

    Returns Promise<void>

  • Type Parameters

    • U extends keyof QueueListener<DataType, ResultType, NameType>

    Parameters

    • eventName: U
    • listener: QueueListener<DataType, ReturnType, NameType>[U]

    Returns Queue<DataType, ReturnType, NameType>

  • Type Parameters

    • U extends keyof QueueListener<DataType, ResultType, NameType>

    Parameters

    • event: U
    • listener: QueueListener<DataType, ReturnType, NameType>[U]

    Returns Queue<DataType, ReturnType, NameType>

  • Type Parameters

    • U extends keyof QueueListener<DataType, ResultType, NameType>

    Parameters

    • event: U
    • listener: QueueListener<DataType, ReturnType, NameType>[U]

    Returns Queue<DataType, ReturnType, NameType>

  • Pauses the processing of this queue globally.

    We use an atomic RENAME operation on the wait queue. Since we have blocking calls with BRPOPLPUSH on the wait queue, as long as the queue is renamed to 'paused', no new jobs will be processed (the current ones will run until finalized).

    Adding jobs requires a LUA script to check first if the paused list exist and in that case it will add it there instead of the wait list.

    Returns Promise<void>

  • Pauses the processing of a specific group globally.

    Adding jobs requires a LUA script to check first if the paused list exist and in that case it will add it there instead of the wait list or group list.

    Parameters

    • groupId: string | number

    Returns Promise<boolean>

  • Removes the given job from the queue as well as all its dependencies.

    Parameters

    • jobId: string

      The id of the job to remove

    Returns Promise<number>

    1 if it managed to remove the job or 0 if the job or any of its dependencies were locked.

  • Removes a repeatable job.

    Note: you need to use the exact same repeatOpts when deleting a repeatable job than when adding it.

    Parameters

    • name: NameType
    • repeatOpts: RepeatOptions
    • Optional jobId: string

    Returns Promise<boolean>

    See

    removeRepeatableByKey

  • Removes a repeatable job by its key. Note that the key is the one used to store the repeatable job metadata and not one of the job iterations themselves. You can use "getRepeatableJobs" in order to get the keys.

    Parameters

    • key: string

      to the repeatable job.

    Returns Promise<boolean>

    See

    getRepeatableJobs

  • Repairs a maxed group.

    It seems that in some unknown situations a group can become maxed although there are no active jobs in the group. This function will try to repair this situation.

    Parameters

    • groupId: string

      the group to repair

    Returns Promise<any>

  • Resumes the processing of this queue globally.

    The method reverses the pause operation by resuming the processing of the queue.

    Returns Promise<void>

  • Resumes the processing of a specific group globally.

    The method reverses the pause operation by resuming the processing of the group.

    Parameters

    • groupId: string | number

      the group to resume

    Returns Promise<boolean>

  • Retry all the failed jobs.

    Parameters

    • Optional opts: {
          count?: number;
          state?: FinishedStatus;
          timestamp?: number;
      }

      contains number to limit how many jobs will be moved to wait status per iteration, state (failed, completed) failed by default or from which timestamp.

      • Optional count?: number
      • Optional state?: FinishedStatus
      • Optional timestamp?: number

    Returns Promise<void>

  • Trim the event stream to an approximately maxLength.

    Parameters

    • maxLength: number

    Returns Promise<number>

  • Returns Promise<RedisClient>

Generated using TypeDoc