Class JobPro<DataType, ReturnType, NameType>

Type Parameters

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

Hierarchy (view full)

  • Job<DataType, ReturnType, NameType>
    • JobPro

Constructors

  • Parameters

    • queue: MinimalQueue
    • name: NameType

      The name of the Job

    • data: DataType

      The payload for this job.

    • opts: JobsProOptions = {}

      The options object for this job.

    • Optional id: string

    Returns JobPro<DataType, ReturnType, NameType>

Properties

gid: string | number

Methods

  • Prepares a job to be passed to Sandbox.

    Returns JobProJsonSandbox

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

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

  • 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

  • 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

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

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

    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>