A customized implementation of the RateLimitedQueueClient that uses axios to make requests and returns the responses via amqplib. Works with the amqplib-oop-axios Adapter.

Example

import { AmqplibAxiosWorker } from '@jakguru/amqplib-oop-axios'

const worker = new AmqplibAxiosWorker(
'example-queue',
{}, // amqplib connection options
{
interval: 1000, // 1 second in ms
perInterval: 10, // 10 requests per interval
autostart: true,
},
{
baseURL: 'https://some-domain.com/api',
}
)
// Optional: Update the axios defaults
worker.defaults.headers.common['Authorization'] = AUTH_TOKEN;

// Optional: Add interceptors
worker.interceptors.request.use(function (config) {
// Do something before request is sent
return config;
}, function (error) {
// Do something with request error
return Promise.reject(error);
});

Hierarchy

  • AmqplibAxiosWorker

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

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

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