Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a queue registry #3030

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

manast
Copy link
Contributor

@manast manast commented Jan 26, 2025

Why

To be able to efficiently get all the bullmq queues that are available in a Redis host. This feature makes
queue discovery a mostly O(1) operation instead of O(n).

How

Added a new key with a fixed name: "bullmq:registry", that holds a ZSET with the fully queue qualified names. This queue names will be kept in the registry until the queue is completely obliterated.

Additional Notes (Optional)

@manast manast requested a review from roggervalf January 26, 2025 10:55
@manast manast requested a review from fgozdz January 26, 2025 11:46
@@ -0,0 +1 @@
export const BullMQRegistryKey = 'bullmq:registry';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use bull as prefix for all our keys, do we really need to change that pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, because this is a global key, if we used a prefix then we would not be able to auto-discover the queues defeating the whole purpose. The idea is that a UI can easily get all the queues available in a Redis instance.

@@ -1464,6 +1465,7 @@ export class Scripts {
const client = await this.queue.client;

const keys: (string | number)[] = [
BullMQRegistryKey,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have this class for handling queue keys, https://github.com/taskforcesh/bullmq/blob/master/src/classes/queue-keys.ts we can add a new method to handle global keys

Copy link
Contributor Author

@manast manast Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this is not really a Queue key, so I am not sure it fits so well on a class that generates queue keys :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants