Class Worker<DataType, ResultType, NameType>

See

Worker

Type Parameters

  • DataType = any

  • ResultType = any

  • NameType extends string = string

Hierarchy

  • Worker<DataType, ResultType, NameType>
    • Worker

Constructors

  • Type Parameters

    • DataType = any

    • ResultType = any

    • NameType extends string = string

    Parameters

    Returns Worker<DataType, ResultType, NameType>

Properties

closing: Promise<void>
id: string
keys: KeysMap
name: string
toKey: ((type) => string)

Type declaration

    • (type): string
    • Parameters

      • type: string

      Returns string

RateLimitError: (() => Error) = Worker.RateLimitError

Type declaration

    • (): Error
    • Returns Error

Accessors

  • get client(): Promise<RedisClient>
  • Returns a promise that resolves to a redis client. Normally used only by subclasses.

    Returns Promise<RedisClient>

  • set concurrency(concurrency): void
  • Parameters

    • concurrency: number

    Returns void

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

    Returns string

  • get repeat(): Promise<Repeat>
  • Returns Promise<Repeat>

Methods

  • Closes the worker and related redis connections.

    This method waits for current jobs to finalize before returning.

    Parameters

    • Optional force: boolean

      Use force boolean parameter if you do not want to wait for current jobs to be processed.

    Returns Promise<void>

    Promise that resolves when the worker has been closed.

  • This function is exposed only for testing purposes.

    Parameters

    • Optional milliseconds: number

    Returns Promise<void>

  • Force disconnects a connection.

    Returns Promise<void>

  • Type Parameters

    Parameters

    • event: U
    • Rest ...args: Parameters<WorkerListener<DataType, ResultType, NameType>[U]>

    Returns boolean

  • Returns a promise that resolves to the next job in queue.

    Parameters

    • token: string

      worker token to be assigned to retrieved job

    • Optional __namedParameters: GetNextJobOptions

    Returns Promise<Job<DataType, ResultType, NameType>>

    a Job or undefined if no job was available in the queue.

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

  • Type Parameters

    Parameters

    • eventName: U
    • listener: WorkerListener<DataType, ResultType, NameType>[U]

    Returns Worker<DataType, ResultType, NameType>

  • Type Parameters

    Parameters

    Returns Worker<DataType, ResultType, NameType>

  • Type Parameters

    Parameters

    Returns Worker<DataType, ResultType, NameType>

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

    Parameters

    • Optional doNotWaitActive: boolean

    Returns Promise<void>

  • Parameters

    • job: Job<DataType, ResultType, NameType>
    • token: string
    • fetchNextCallback: (() => boolean)
        • (): boolean
        • Returns boolean

    • jobsInProgress: Set<{
          job: Job<any, any, string>;
          ts: number;
      }>

    Returns Promise<void | Job<DataType, ResultType, NameType>>

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

  • Overrides the rate limit so that it becomes active for the given group.

    Parameters

    • job: Job<any, any, string>

      Job currently being processed, and whose group we want to rate limit.

    • expireTimeMs: number

      Expire time in ms of this rate limit.

    Returns Promise<void>

  • Resumes processing of this worker (if paused).

    Returns void

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

  • Waits until the worker is ready to start processing jobs. In general only useful when writing tests.

    Returns Promise<RedisClient>

Generated using TypeDoc