Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Job<DataType, ReturnType, NameType>

Type parameters

  • DataType = any

  • ReturnType = any

  • NameType: string = string

Hierarchy

  • Job<DataType, ReturnType, NameType>
    • Job

Index

Constructors

  • new Job<DataType, ReturnType, NameType>(queue: MinimalQueue, name: NameType, data: DataType, opts?: JobsProOptions, id?: string): Job<DataType, ReturnType, NameType>
  • Type parameters

    • DataType = any

    • ReturnType = any

    • NameType: string = string

    Parameters

    • queue: MinimalQueue
    • name: NameType
    • data: DataType
    • opts: JobsProOptions = {}
    • Optional id: string

    Returns Job<DataType, ReturnType, NameType>

Properties

gid: string | number

Methods

  • asJSONSandbox(): JobProJsonSandbox
  • Prepares a job to be passed to Sandbox.

    Returns JobProJsonSandbox

  • moveToCompleted(returnValue: ReturnType, token: string, fetchNext?: boolean): Promise<[] | JobData>
  • Moves a job to the completed queue. Returned job to be used with Queue.prototype.nextJobFromJobData.

    Parameters

    • returnValue: ReturnType

      The jobs success message.

    • token: string

      Worker token used to acquire completed job.

    • fetchNext: boolean = true

      True when wanting to fetch the next job.

    Returns Promise<[] | JobData>

    Returns the jobData of the next job in the waiting queue.

  • moveToDelayed(timestamp: number, token?: string): Promise<void>
  • Moves the job to the delay set.

    Parameters

    • timestamp: number

      timestamp where the job should be moved back to "wait"

    • Optional token: string

      token to check job is locked by current worker

    Returns Promise<void>

  • moveToFailed(err: Error, token: string, fetchNext?: boolean): Promise<void>
  • Moves a job to the failed queue.

    Parameters

    • err: Error

      the jobs error message.

    • token: string

      token to check job is locked by current worker

    • fetchNext: boolean = false

      true when wanting to fetch the next job

    Returns Promise<void>

    void

  • moveToWaitingChildren(token: string, opts?: MoveToWaitingChildrenOpts): Promise<boolean>
  • Moves the job to the waiting-children set.

    Parameters

    • token: string

      Token to check job is locked by current worker

    • opts: MoveToWaitingChildrenOpts = {}

      The options bag for moving a job to waiting-children.

    Returns Promise<boolean>

    true if the job was moved

  • remove(): Promise<void>
  • Completely remove the job from the queue. Note, this call will throw an exception if the job is being processed when the call is performed.

    Returns Promise<void>

  • fromJSON<T, R, N>(queue: MinimalQueue, json: JobProJsonRaw, jobId?: string): Job<T, R, N>
  • Instantiates a Job from a JobJsonRaw object (coming from a deserialized JSON object)

    Type parameters

    • T = any

    • R = any

    • N: string = string

    Parameters

    • queue: MinimalQueue

      the queue where the job belongs to.

    • json: JobProJsonRaw

      the plain object containing the job.

    • Optional jobId: string

      an optional job id (overrides the id coming from the JSON object)

    Returns Job<T, R, N>

Generated using TypeDoc