Class JobHandler<Type, Data, CustomHeaders, CustomOptions>

JobHandler class

Type Parameters

  • Type extends string

    Job type, used as selector for strategies in job processors

  • Data = unknown

    Job payload

  • CustomHeaders extends Record<string, any> = AnyHeaders

    Custom headers, used to pass specific information for job processors

  • CustomOptions extends Record<string, any> = AnyOptions

    Custom options, used to pass specific information for job processors

Hierarchy

  • EventEmitter
    • JobHandler

Implements

Constructors

Properties

createdAt: Date

Date object with the timestamp when the job was created

jobUserId: string

User job request identifier, defined by the user

jobUserUUID: string

Unique user job request identification, based on jobUserId

Job meta information, used to pass specific information for job processors

type: Type

Job type, used as selector for strategies in job processors

uuid: string

Unique job processing identification

Accessors

  • get errors(): undefined | Multi
  • Errors raised during the job

    Returns undefined | Multi

  • get hasErrors(): boolean
  • True if the job task raised any error

    Returns boolean

  • get processTime(): number
  • Return the process time in msec

    Returns number

Methods

  • Add a new error in the job

    Parameters

    Returns void

  • Register an event listener over the done event, which is emitted when a job has ended, either due to completion or failure.

    Parameters

    Returns this

  • Notify the results of the process

    Parameters

    • Optionalerror: Crash

      conditional parameter for error notification

    Returns void

  • Removes the specified listener from the listener array for the done event.

    Parameters

    Returns this

  • Register an event listener over the done event, which is emitted when a job has ended, either due to completion or failure.

    Parameters

    Returns this

  • Registers a one-time event listener over the done event, which is emitted when a job has ended, either due to completion or failure.

    Parameters

    Returns this

  • Registers a event listener over the done event, at the beginning of the listeners array, which is emitted when a job has ended, either due to completion or failure.

    Parameters

    Returns this

  • Registers a one-time event listener over the done event, at the beginning of the listeners array, which is emitted when a job has ended, either due to completion or failure.

    Parameters

    Returns this

  • Removes all listeners, or those of the specified event.

    Parameters

    • Optionalevent: "done"

      done event

    Returns this

  • Removes the specified listener from the listener array for the done event.

    Parameters

    Returns this