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 support for redis+sentinel url #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"bunyan": "^1.8.12",
"express": "^4.17.1",
"prom-client": "^12.0.0",
"redis-url-plus": "^1.0.0",
"tslib": "^2.0.0",
"uuid": "^8.0.0",
"yargs": "^15.1.0"
Expand Down
5 changes: 3 additions & 2 deletions src/metricCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as Logger from 'bunyan';
import { EventEmitter } from 'events';
import IoRedis from 'ioredis';
import { register as globalRegister, Registry } from 'prom-client';
import redisUrlPlus from 'redis-url-plus';

import { logger as globalLogger } from './logger';
import { getJobCompleteStats, getStats, makeGuages, QueueGauges } from './queueGauges';
Expand Down Expand Up @@ -44,7 +45,7 @@ export class MetricCollector {
) {
const { logger, autoDiscover, redis, metricPrefix, ...bullOpts } = opts;
this.redisUri = redis;
this.defaultRedisClient = new IoRedis(this.redisUri);
this.defaultRedisClient = new IoRedis(redisUrlPlus(this.redisUri));
this.defaultRedisClient.setMaxListeners(32);
this.bullOpts = bullOpts;
this.logger = logger || globalLogger;
Expand All @@ -56,7 +57,7 @@ export class MetricCollector {
if (_type === 'client') {
return this.defaultRedisClient!;
}
return new IoRedis(this.redisUri, redisOpts);
return new IoRedis(Object.assign(redisUrlPlus(this.redisUri), redisOpts));
}

private addToQueueSet(names: string[]): void {
Expand Down
3 changes: 3 additions & 0 deletions src/redis-url-plus.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module 'redis-url-plus' {
export default function redisUrlPlus(url: string): import('ioredis').RedisOptions;
}
Loading