Class Worker<DataType, ResultType, NameType>

This class represents a worker that is able to process jobs from the queue. As soon as the class is instantiated and a connection to Redis is established it will start processing jobs.

Type Parameters

  • DataType = any
  • ResultType = any
  • NameType extends string = string

Hierarchy (view full)

Constructors

Properties

closing: Promise<void>
id: string
keys: KeysMap
name: string

The name of the queue.

Options for the queue.

qualifiedName: string
toKey: ((type) => string)

Type declaration

    • (type): string
    • Parameters

      • type: string

      Returns string

Accessors

  • get redisVersion(): string
  • Returns the version of the Redis instance the client is connected to,

    Returns string

Methods

  • Closes the worker and related redis connections.

    This method waits for current jobs to finalize before returning.

    Parameters

    • force: boolean = false

      Use force boolean parameter if you do not want to wait for current jobs to be processed. When using telemetry, be mindful that it can interfere with the proper closure of spans, potentially preventing them from being exported.

    Returns Promise<void>

    Promise that resolves when the worker has been closed.

  • This function is exposed only for testing purposes.

    Parameters

    • Optional milliseconds: number
    • Optional abortController: AbortController

    Returns Promise<void>

  • Checks if worker is paused.

    Returns boolean

    true if worker is paused, false otherwise.

  • Checks if worker is currently running.

    Returns boolean

    true if worker is running, false otherwise.

  • Pauses the processing of this queue only for this worker.

    Parameters

    • Optional doNotWaitActive: boolean

    Returns Promise<void>

  • Overrides the rate limit to be active for the next jobs.

    Parameters

    • expireTimeMs: number

      expire time in ms of this rate limit.

    Returns Promise<void>

    Deprecated

    This method is deprecated and will be removed in v6. Use queue.rateLimit method instead.

  • Resumes processing of this worker (if paused).

    Returns void

  • Manually starts the stalled checker. The check will run once as soon as this method is called, and then every opts.stalledInterval milliseconds until the worker is closed. Note: Normally you do not need to call this method, since the stalled checker is automatically started when the worker starts processing jobs after calling run. However if you want to process the jobs manually you need to call this method to start the stalled checker.

    Returns Promise<void>

  • Wraps the code with telemetry and provides a span for configuration.

    Type Parameters

    • T

    Parameters

    • spanKind: SpanKind

      kind of the span: Producer, Consumer, Internal

    • operation: string

      operation name (such as add, process, etc)

    • destination: string

      destination name (normally the queue name)

    • callback: ((span?, dstPropagationMetadata?) => T | Promise<T>)

      code to wrap with telemetry

        • (span?, dstPropagationMetadata?): T | Promise<T>
        • Parameters

          • Optional span: Span<any>
          • Optional dstPropagationMetadata: string

          Returns T | Promise<T>

    • Optional srcPropagationMetadata: string

    Returns Promise<T | Promise<T>>

Generated using TypeDoc