Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
feat(cli): add optional redis prefix option for bull/bullmq
Browse files Browse the repository at this point in the history
  • Loading branch information
leoperria committed Jan 13, 2023
1 parent 1759a9d commit a5cf3b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Options:
--bullmq use bullmq instead of bull
-p, --port <number> server's port (default: "3000")
--host <string> server's host (default: "localhost")
--prefix <string> redis key prefix (bull/bullmq)
-m, --metrics enable metrics collector
--max-metrics <number> max metrics (default: "100")
--metrics-interval <number> metrics collection interval in seconds (default: "3600")
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ program
.option('--bullmq', 'use bullmq instead of bull')
.option('-p, --port <number>', "server's port", '3000')
.option('--host <string>', "server's host", 'localhost')
.option('--prefix <string>', 'redis key prefix', undefined)
.option('-m, --metrics', 'enable metrics collector')
.option('--max-metrics <number>', 'max metrics', '100')
.option(
Expand All @@ -44,13 +45,16 @@ const options = program.opts();
require('@bull-monitor/root/dist/bullmq-adapter').BullMQAdapter;
return new Adapter(
new BullMqQueue(name, {
...(options.prefix ? {prefix: options.prefix}: {}),
connection,
})
);
} else {
const Adapter =
require('@bull-monitor/root/dist/bull-adapter').BullAdapter;
return new Adapter(new BullQueue(name, options.redisUri));
return new Adapter(new BullQueue(name, options.redisUri, {
...(options.prefix ? {prefix: options.prefix}: {})
}));
}
}),
metrics: options.metrics && {
Expand Down

0 comments on commit a5cf3b4

Please sign in to comment.