Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Worker

Hierarchy

  • EventEmitter
    • Worker

Index

Constructors

constructor

  • new Worker(options: any, jobs?: {}): Worker

Properties

connection

connection: Connection

error

error: Error

id

id: number

job

job: Job<any>

jobs

jobs: Jobs

name

name: string

options

options: WorkerOptions

originalQueue

originalQueue: string

pingTimer

pingTimer: Timeout

queue

queue: string

queueObject

queueObject: Queue

queues

queues: string[]

ready

ready: boolean

result

result: any

running

running: boolean

started

started: boolean

working

working: boolean

Static Readonly captureRejectionSymbol

captureRejectionSymbol: typeof captureRejectionSymbol

Static captureRejections

captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): Worker
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Worker

checkQueues

  • checkQueues(): Promise<void>

Private completeJob

  • completeJob(toRespond: boolean, startedAt: number): Promise<void>

connect

  • connect(): Promise<void>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

end

  • end(): any

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

Private fail

  • fail(err: any, duration: number): Promise<void>

Private failurePayload

  • failurePayload(err: any, job: any): { backtrace: any; error: any; exception: any; failed_at: string; payload: any; queue: string; worker: string }
  • Parameters

    • err: any
    • job: any

    Returns { backtrace: any; error: any; exception: any; failed_at: string; payload: any; queue: string; worker: string }

    • backtrace: any
    • error: any
    • exception: any
    • failed_at: string
    • payload: any
    • queue: string
    • worker: string

Private getJob

  • getJob(): Promise<{}>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

Private init

  • init(): Promise<void>

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): Worker
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Worker

on

  • on(event: "start" | "end" | "pause", cb: () => void): Worker
  • on(event: "cleaning_worker", cb: (worker: Worker, pid: string) => void): Worker
  • on(event: "poll", cb: (queue: string) => void): Worker
  • on(event: "ping", cb: (time: number) => void): Worker
  • on(event: "job", cb: (queue: string, job: Job<any> | JobEmit) => void): Worker
  • on(event: "reEnqueue", cb: (queue: string, job: JobEmit, plugin: string) => void): Worker
  • on(event: "success", cb: (queue: string, job: JobEmit, result: any, duration: number) => void): Worker
  • on(event: "failure", cb: (queue: string, job: JobEmit, failure: any, duration: number) => void): Worker
  • on(event: "error", cb: (error: Error, queue: string, job: Job<any> | JobEmit) => void): Worker
  • Parameters

    • event: "start" | "end" | "pause"
    • cb: () => void
        • (): void
        • Returns void

    Returns Worker

  • Parameters

    • event: "cleaning_worker"
    • cb: (worker: Worker, pid: string) => void
        • (worker: Worker, pid: string): void
        • Parameters

          Returns void

    Returns Worker

  • Parameters

    • event: "poll"
    • cb: (queue: string) => void
        • (queue: string): void
        • Parameters

          • queue: string

          Returns void

    Returns Worker

  • Parameters

    • event: "ping"
    • cb: (time: number) => void
        • (time: number): void
        • Parameters

          • time: number

          Returns void

    Returns Worker

  • Parameters

    • event: "job"
    • cb: (queue: string, job: Job<any> | JobEmit) => void
        • Parameters

          Returns void

    Returns Worker

  • Parameters

    • event: "reEnqueue"
    • cb: (queue: string, job: JobEmit, plugin: string) => void
        • (queue: string, job: JobEmit, plugin: string): void
        • Parameters

          • queue: string
          • job: JobEmit
          • plugin: string

          Returns void

    Returns Worker

  • Parameters

    • event: "success"
    • cb: (queue: string, job: JobEmit, result: any, duration: number) => void
        • (queue: string, job: JobEmit, result: any, duration: number): void
        • Parameters

          • queue: string
          • job: JobEmit
          • result: any
          • duration: number

          Returns void

    Returns Worker

  • Parameters

    • event: "failure"
    • cb: (queue: string, job: JobEmit, failure: any, duration: number) => void
        • (queue: string, job: JobEmit, failure: any, duration: number): void
        • Parameters

          • queue: string
          • job: JobEmit
          • failure: any
          • duration: number

          Returns void

    Returns Worker

  • Parameters

    • event: "error"
    • cb: (error: Error, queue: string, job: Job<any> | JobEmit) => void
        • (error: Error, queue: string, job: Job<any> | JobEmit): void
        • Parameters

          • error: Error
          • queue: string
          • job: Job<any> | JobEmit

          Returns void

    Returns Worker

once

  • once(event: "start" | "end" | "pause", cb: () => void): Worker
  • once(event: "cleaning_worker", cb: (worker: Worker, pid: string) => void): Worker
  • once(event: "poll", cb: (queue: string) => void): Worker
  • once(event: "ping", cb: (time: number) => void): Worker
  • once(event: "job", cb: (queue: string, job: Job<any> | JobEmit) => void): Worker
  • once(event: "reEnqueue", cb: (queue: string, job: Job<any> | JobEmit, plugin: string) => void): Worker
  • once(event: "success", cb: (queue: string, job: Job<any> | JobEmit, result: any) => void): Worker
  • once(event: "failure", cb: (queue: string, job: Job<any> | JobEmit, failure: any) => void): Worker
  • once(event: "error", cb: (error: Error, queue: string, job: Job<any> | JobEmit) => void): Worker

Private pause

  • pause(): Promise<void>

Private perform

  • perform(job: any): Promise<void>

performInline

  • performInline(func: any, args?: any[]): Promise<any>

Private ping

  • ping(): Promise<void>

Private poll

  • poll(nQueue?: number): any

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): Worker
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Worker

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): Worker
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Worker

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event: WorkerEvent): Worker

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): Worker
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Worker

setMaxListeners

  • setMaxListeners(n: number): Worker
  • Parameters

    • n: number

    Returns Worker

start

  • start(): Promise<void>

Private stringQueues

  • stringQueues(): string

Private succeed

  • succeed(job: any, duration: number): Promise<void>

Private track

  • track(): Promise<number>

Private untrack

  • untrack(): Promise<void>

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static on

  • on(emitter: EventEmitter, event: string): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string

    Returns AsyncIterableIterator<any>

Static once

  • once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>
  • once(emitter: DOMEventTarget, event: string): Promise<any[]>
  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string

    Returns Promise<any[]>

Generated using TypeDoc