Class RateLimitedQueueClient<ItemType>

A rate-limited queue client that allows you to limit the rate at which messages are processed.

Typeparam

ItemType The type of items in the queue.

Type Parameters

  • ItemType = any

Hierarchy

  • RateLimitedQueueClient

Constructors

Accessors

  • get isShutDown(): boolean
  • Returns a boolean indicating whether or not the queue has been shut down.

    Returns boolean

    A boolean indicating whether or not the queue has been shut down.

  • get running(): boolean
  • Returns a boolean indicating whether or not the queue is running.

    Returns boolean

    A boolean indicating whether or not the queue is running.

  • get working(): boolean
  • Returns a boolean indicating whether or not the queue is currently processing a tick.

    Returns boolean

    A boolean indicating whether or not the queue is currently processing a tick.

Methods

  • Adds an item to the rate-limited queue.

    Parameters

    • item: ItemType

      The item to add to the queue.

    Returns Promise<boolean>

    A Promise that resolves when the item has been added to the queue.

  • Adds multiple items to the rate-limited queue in bulk.

    Parameters

    • items: ItemType[]

      An array of items to add to the queue.

    Returns Promise<boolean[]>

    A Promise that resolves when all items have been added to the queue.

  • Gets the total number of jobs in the queue (waiting + active).

    Returns Promise<number>

    A Promise that resolves to the total number of jobs in the queue.

  • Sets the callback function to be called when the rate-limited queue spills.

    Parameters

    Returns void

    void

    Typeparam

    ItemType The type of items in the queue.

  • Shuts down the queue.

    Returns Promise<void>

    A Promise that resolves when the queue has shut down.

    Remarks

    This will stop the queue and close the Connection connection.

  • Starts processing the queue. If the queue is already running, it will wait for the current tick to complete before starting a new one.

    Returns Promise<void>

    A Promise that resolves when the queue has started.

  • Stops processing the queue. If the queue is currently working, it will wait for the current tick to complete before stopping.

    Returns Promise<void>

    A Promise that resolves when the queue has stopped.