Class Queue<DataType, ReturnType, NameType>

QueuePro extends the functionality of Queue with additional features for handling job groups, rate limiting, concurrency per group, and more.

Type Parameters

  • DataType = any

    The type of the job data.

  • ReturnType = any

    The type of the job result.

  • NameType extends string = string

    The type of the job name.

Hierarchy

  • Queue<Job<DataType, ReturnType, NameType>>
    • Queue

Constructors

  • Type Parameters

    • DataType = any

    • ReturnType = any

    • NameType extends string = string

    Parameters

    Returns Queue<DataType, ReturnType, NameType>

Properties

Accessors

  • get metaValues(): Record<string, string | number>
  • Returns Record<string, string | number>

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 all the jobs that are part of a group.

    Parameters

    • groupId: string | number

    Returns Promise<void>

  • Deletes group concurrency.

    Parameters

    • groupId: string | number

    Returns Promise<number>

  • Returns the number of jobs per priority.

    Parameters

    • groupId: string
    • priorities: number[]

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

  • Gets the active count of jobs inside a given group id. It will only return data when using concurrency per group, otherwise it will return NaN.

    Parameters

    • groupId: string | number

    Returns Promise<number>

  • Gets group concurrency.

    Parameters

    • groupId: string | number

    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>

  • Returns the time to live for a rate limited key in milliseconds.

    Parameters

    • groupId: string | number

      group identifier

    • Optional maxJobs: number

      max jobs to be considered in rate limit state. If not passed it will return the remaining ttl without considering if max jobs is excedeed.

    Returns Promise<number>

    -2 if the key does not exist. -1 if the key exists but has no associated expire.

  • 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.

    Parameters

    • limit: number = 100

      limit of groups per each iteration

    Returns Promise<number>

  • Get library version.

    Returns Promise<string>

    the content of the meta.library field.

  • Parameters

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

    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>

  • 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

    • Optional concurrency: number

      maximum number of simultaneous jobs that the workers can handle within a specific group

    Returns Promise<any>

  • Repairs stalled key when you are migrating from v4 or below to v6 or above. This key used a zset and now it uses a set, this is why this method is needed. An error like: 'WRONGTYPE Operation against a key holding the wrong kind of value' in moveStalledJobsToWait script is a good indicator of this change. Note: Migration from v5 to v6 won't need to call this method

    Returns Promise<any>

  • 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>

  • Sets group concurrency.

    Parameters

    • groupId: string | number
    • concurrency: number

    Returns Promise<number>

Generated using TypeDoc