Skip to content

Commit bb8b64d

Browse files
Merge pull request #13 from InternetMaximalism/tls
fix redis
2 parents 192fcf1 + 5ef1261 commit bb8b64d

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

packages/shared/src/lib/queue.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ export class QueueManager {
2828
};
2929

3030
constructor(queueName: QueueNameType, options?: QueueOptions) {
31+
const redisUrl = this.getRedisURL();
3132
const defaultOptions: QueueOptions = {};
32-
this.queue = new Queue<QueueJobData>(queueName, config.REDIS_URL, {
33+
this.queue = new Queue<QueueJobData>(queueName, redisUrl, {
3334
...defaultOptions,
3435
...options,
3536
});
@@ -47,6 +48,16 @@ export class QueueManager {
4748
});
4849
}
4950

51+
private getRedisURL(): string {
52+
const hasQueryParams = config.REDIS_URL.includes("?");
53+
54+
if (config.REDIS_URL.includes("rediss")) {
55+
return hasQueryParams ? `${config.REDIS_URL}&tls=true` : `${config.REDIS_URL}?tls=true`;
56+
}
57+
58+
return config.REDIS_URL;
59+
}
60+
5061
public static getInstance(queueName: QueueNameType) {
5162
if (!QueueManager.instance) {
5263
QueueManager.instance = new QueueManager(queueName);

packages/shared/src/lib/redis.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ export class RedisClient {
1111
return;
1212
}
1313

14-
const redisUrl = this.getRedisURL();
15-
16-
this.client = new Redis(redisUrl, {
14+
this.client = new Redis(config.REDIS_URL, {
1715
reconnectOnError: (err) => {
1816
const targetError = "READONLY";
1917
if (err.message.includes(targetError)) {
@@ -32,16 +30,6 @@ export class RedisClient {
3230
});
3331
}
3432

35-
private getRedisURL(): string {
36-
const hasQueryParams = config.REDIS_URL.includes("?");
37-
38-
if (config.REDIS_URL.includes("rediss")) {
39-
return hasQueryParams ? `${config.REDIS_URL}&tls=true` : `${config.REDIS_URL}?tls=true`;
40-
}
41-
42-
return config.REDIS_URL;
43-
}
44-
4533
public static getInstance(): RedisClient {
4634
if (!RedisClient.instance) {
4735
RedisClient.instance = new RedisClient();

0 commit comments

Comments
 (0)