Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MultiWorker

Hierarchy

  • EventEmitter
    • MultiWorker

Index

Constructors

constructor

  • new MultiWorker(options: any, jobs: any): MultiWorker

Properties

checkTimer

checkTimer: Timeout

eventLoopBlocked

eventLoopBlocked: boolean

eventLoopCheckCounter

eventLoopCheckCounter: number

eventLoopDelay

eventLoopDelay: number

jobs

jobs: Jobs

name

name: string

options

options: MultiWorkerOptions

running

running: boolean

stopInProcess

stopInProcess: boolean

workers

workers: Worker[]

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

Private PollEventLoopDelay

  • PollEventLoopDelay(): void

addListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns MultiWorker

Private checkWorkers

  • checkWorkers(): Promise<{ eventLoopDelay: number; verb: any }>

Private checkWrapper

  • checkWrapper(): Promise<void>

Private cleanupWorker

  • cleanupWorker(worker: any): Promise<void>

emit

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

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

    Returns boolean

end

  • end(): Promise<void>

eventNames

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

getMaxListeners

  • getMaxListeners(): number
  • Returns number

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): MultiWorker
  • Parameters

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

          • Rest ...args: any[]

          Returns void

    Returns MultiWorker

on

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

    • event: "start" | "end"
    • cb: (workerId: number) => void
        • (workerId: number): void
        • Parameters

          • workerId: number

          Returns void

    Returns MultiWorker

  • Parameters

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

          • workerId: number
          • worker: Worker
          • pid: number

          Returns void

    Returns MultiWorker

  • Parameters

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

          • workerId: number
          • queue: string

          Returns void

    Returns MultiWorker

  • Parameters

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

          • workerId: number
          • time: number

          Returns void

    Returns MultiWorker

  • Parameters

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

          • workerId: number
          • queue: string
          • job: Job<any> | JobEmit

          Returns void

    Returns MultiWorker

  • Parameters

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

          • workerId: number
          • queue: string
          • job: Job<any> | JobEmit
          • plugin: string

          Returns void

    Returns MultiWorker

  • Parameters

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

          • workerId: number
          • queue: string
          • job: Job<any> | JobEmit
          • result: any
          • duration: number

          Returns void

    Returns MultiWorker

  • Parameters

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

          • workerId: number
          • queue: string
          • job: Job<any> | JobEmit
          • failure: any
          • duration: number

          Returns void

    Returns MultiWorker

  • Parameters

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

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

          Returns void

    Returns MultiWorker

  • Parameters

    • event: "pause"
    • cb: (workerId: number) => void
        • (workerId: number): void
        • Parameters

          • workerId: number

          Returns void

    Returns MultiWorker

  • Parameters

    • event: "multiWorkerAction"
    • cb: (verb: string, delay: number) => void
        • (verb: string, delay: number): void
        • Parameters

          • verb: string
          • delay: number

          Returns void

    Returns MultiWorker

once

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

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

          • Rest ...args: any[]

          Returns void

    Returns MultiWorker

prependListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns MultiWorker

prependOnceListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns MultiWorker

rawListeners

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

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): MultiWorker
  • Parameters

    • Optional event: string | symbol

    Returns MultiWorker

removeListener

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

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

          • Rest ...args: any[]

          Returns void

    Returns MultiWorker

setMaxListeners

  • Parameters

    • n: number

    Returns MultiWorker

start

  • start(): void

Private startWorker

  • startWorker(): Promise<void>

stop

  • stop(): Promise<void>

Private stopWait

  • stopWait(): any

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, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns AsyncIterableIterator<any>

Static once

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

    • emitter: NodeEventTarget
    • event: string | symbol
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

Generated using TypeDoc