Class JobPro<DataType, ReturnType, NameType>

See

Job

Type Parameters

  • DataType = any
  • ReturnType = any
  • NameType extends string = string

Hierarchy

Constructors

Properties

gid: string | number
id?: string

Methods

  • Prepares a job to be passed to Sandbox.

    Returns JobProJsonSandbox

  • Parameters

    • token: string
    • duration: number

    Returns Promise<number>

  • 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<void | any[]>

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

  • 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 | any[]>

    void

  • Set job as failed. This method will set the current job instance as failed, it is useful when processing batches to mark a certain job in a batch as failed while completing the rest.

    Parameters

    • err: Error

      The error object to be associated with the job.

    Returns void

  • Instantiates a Job from a JobJsonRaw object (coming from a deserialized JSON object)

    Type Parameters

    • T = any
    • R = any
    • N extends 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 JobPro<T, R, N>