Skip to content

Commit

Permalink
feat: add support for redis+sentinel url
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoPoi committed Feb 15, 2022
1 parent 9acc9b2 commit 0c44c51
Show file tree
Hide file tree
Showing 4 changed files with 4,978 additions and 4,876 deletions.
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

0 comments on commit 0c44c51

Please sign in to comment.