npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bull-qm

v2.0.0

Published

Queue Manager for Bull

Downloads

64

Readme

Build Status Coverage Status

Queue Manager for Bull

If you use Bull, you've probably run into a situation in which the number of connections to your redis server skyrocketed. Why? Because each instance of your queues created 3 connections and each instance of your application created each queue. Easily racking up thousands of connections.

Enter the Queue Manager. At least now you can limit the number of connections a single instance makes!

QueueManager ⇐ EventEmitter

QueueManager

Kind: global class
Extends: EventEmitter

new QueueManager(bullOpts)

| Param | Type | Description | | --- | --- | --- | | bullOpts | BullOpts | The options you would normally pass to the bull queue by default |

manager.NUM_CLIENTS ⇒ number

Returns the number of clients connected via this QueueManager (helper for tests)

Kind: instance property of QueueManager
Returns: number - number of clients

manager.client ⇒ IORedis

Returns the client for this QueueManager

Kind: instance property of QueueManager
Returns: IORedis - Client (used for redis cmds)

manager.subscriber ⇒ IORedis

Returns the subscriber instance for this manager. Creates it if it does not exist;

Kind: instance property of QueueManager
Returns: IORedis - Subscriber client

manager.enqueue(name, data, opts) ⇒ Promise.<Job>

Adds a job to a queue with the given name. Relies on QueueManager.getQueue which means the queue will be created. If the queue needs to have special options, make sure the queue is created by using getQueue/createQueue first.

Kind: instance method of QueueManager
Returns: Promise.<Job> - The Job created by Bull

| Param | Type | Description | | --- | --- | --- | | name | string | The name of the queue | | data | Object | The data property for the new job | | opts | JobOpts | Bull job options. |

manager.hasQueue(name) ⇒ Boolean

Simple function to test if a queue has been created or not.

Kind: instance method of QueueManager
Returns: Boolean - True if the queue has been created, false otherwise

| Param | Type | Description | | --- | --- | --- | | name | string | The name of the queue |

manager.getQueue(name, options) ⇒ BullQueue

Gets a specific queue. Creates it if the queue does not exist. If a queue needs special configuration options, they can be called on the first instance of getQueue. QueueManager.createQueue is aliased to this function, so syntactically, you can use that function to denote creation.

Kind: instance method of QueueManager
Returns: BullQueue - The created bull queue

| Param | Type | Description | | --- | --- | --- | | name | string | The name of the queue to create | | options | BullOpts | Options to pass to bull. Options here will override any options provided by default. |

manager.getAllQueues() ⇒ Array.<BullQueue>

Returns an array of all queues

Kind: instance method of QueueManager
Returns: Array.<BullQueue> - array of bull queues

manager.shutdown() ⇒ Promise

Closes all queues managed by this QueueManager

Kind: instance method of QueueManager
Returns: Promise - Resolves when all queues have been closed

manager.createClient(type, redisOpts) ⇒ IORedis

Manages the clients used by queues in this QueueManager instance. Bull can reuse subscriber and client connections, but needs to create separate bclient instances for each queue. This means that the number of clients you have is directly tied to the number of queues you have. You shouldn't have to use the function unless you want to reuse the IORedis connection that the Queue Manager is using

Kind: instance method of QueueManager
Returns: IORedis - An instance of IORedis
See: https://github.com/OptimalBits/bull/blob/develop/PATTERNS.md#reusing-redis-connections

| Param | Type | Description | | --- | --- | --- | | type | string | Type of redis client | | redisOpts | IORedisOpts | The options to pass to redis. |

manager.createQueue(name, options) ⇒ BullQueue

Gets a specific queue. Creates it if the queue does not exist. If a queue needs special configuration options, they can be called on the first instance of getQueue. QueueManager.createQueue is aliased to this function, so syntactically, you can use that function to denote creation.

Kind: instance method of QueueManager
Returns: BullQueue - The created bull queue

| Param | Type | Description | | --- | --- | --- | | name | string | The name of the queue to create | | options | BullOpts | Options to pass to bull. Options here will override any options provided by default. |

manager.createQueue(name, options) ⇒ BullQueue

Gets a specific queue. Creates it if the queue does not exist. If a queue needs special configuration options, they can be called on the first instance of getQueue. QueueManager.createQueue is aliased to this function, so syntactically, you can use that function to denote creation.

Kind: instance method of QueueManager
Returns: BullQueue - The created bull queue

| Param | Type | Description | | --- | --- | --- | | name | string | The name of the queue to create | | options | BullOpts | Options to pass to bull. Options here will override any options provided by default. |

License

© 2020 Mudrekh Goderya MIT