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

add support for bullmq #251

Merged
merged 4 commits into from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/server/queue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,21 @@ class Queues {

_checkConstructors() {
let hasBull = false,
hasBee = false;
hasBee = false,
hasBullMQ = false;
for (const queue of this._config.queues) {
if (queue.type === 'bee') hasBee = true;
else if (queue.type === 'bullmq') hasBullMQ = true;
else hasBull = true;

if (hasBull && hasBee) break;
if (hasBull && hasBee && hasBullMQ) break;
}

return (
(hasBull || hasBee) && (!hasBull || !!this._config.Bull) && (!hasBee || !!this._config.Bee)
(hasBull || hasBee || hasBullMQ) &&
(!hasBull || !!this._config.Bull) &&
(!hasBee || !!this._config.Bee) &&
(!hasBullMQ || !!this._config.BullMQ)
);
}

Expand All @@ -70,6 +75,7 @@ class Queues {
if (tls) redisHost.tls = tls;

const isBee = type === 'bee';
const isBullMQ = type === 'bullmq';

const options = {
redis: redis || url || redisHost,
Expand All @@ -88,6 +94,12 @@ class Queues {
const { Bee } = this._config;
queue = new Bee(name, options);
queue.IS_BEE = true;
} else if (isBullMQ) {
if (queueConfig.createClient) options.createClient = queueConfig.createClient;

const { BullMQ } = this._config;
queue = new BullMQ(name, options);
queue.IS_BULLMQ = true;
} else {
if (queueConfig.createClient) options.createClient = queueConfig.createClient;

Expand Down
2 changes: 2 additions & 0 deletions src/server/views/dashboard/queueDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ async function handler(req, res) {
if (queue.IS_BEE) {
jobCounts = await queue.checkHealth();
delete jobCounts.newestJob;
} else if (queue.IS_BULLMQ) {
jobCounts = await queue.getJobCounts(...QueueHelpers.BULL_STATES);
} else {
jobCounts = await queue.getJobCounts();
}
Expand Down
7 changes: 3 additions & 4 deletions src/server/views/helpers/queueHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ function formatBytes(num) {

const Helpers = {
getStats: async function (queue) {
await queue.client.info(); // update queue.client.serverInfo
const client = await queue.client;
await client.info(); // update queue.client.serverInfo

const stats = _.pickBy(queue.client.serverInfo, (value, key) =>
_.includes(this._usefulMetrics, key)
);
const stats = _.pickBy(client.serverInfo, (value, key) => _.includes(this._usefulMetrics, key));
stats.used_memory = formatBytes(parseInt(stats.used_memory, 10));
stats.total_system_memory = formatBytes(parseInt(stats.total_system_memory, 10));
return stats;
Expand Down