mirror of
https://github.com/docmost/docmost.git
synced 2025-11-15 23:01:11 +10:00
fix: properly support redis db (#517)
This commit is contained in:
@ -36,6 +36,7 @@ export class CollaborationGateway {
|
|||||||
port: this.redisConfig.port,
|
port: this.redisConfig.port,
|
||||||
options: {
|
options: {
|
||||||
password: this.redisConfig.password,
|
password: this.redisConfig.password,
|
||||||
|
db: this.redisConfig.db,
|
||||||
retryStrategy: createRetryStrategy(),
|
retryStrategy: createRetryStrategy(),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -18,15 +18,25 @@ export async function comparePasswordHash(
|
|||||||
export type RedisConfig = {
|
export type RedisConfig = {
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
db: number;
|
||||||
password?: string;
|
password?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function parseRedisUrl(redisUrl: string): RedisConfig {
|
export function parseRedisUrl(redisUrl: string): RedisConfig {
|
||||||
// format - redis[s]://[[username][:password]@][host][:port][/db-number]
|
// format - redis[s]://[[username][:password]@][host][:port][/db-number]
|
||||||
const { hostname, port, password } = new URL(redisUrl);
|
const { hostname, port, password, pathname } = new URL(redisUrl);
|
||||||
const portInt = parseInt(port, 10);
|
const portInt = parseInt(port, 10);
|
||||||
|
|
||||||
return { host: hostname, port: portInt, password };
|
let db: number = 0;
|
||||||
|
// extract db value if present
|
||||||
|
if (pathname.length > 1) {
|
||||||
|
const value = pathname.slice(1);
|
||||||
|
if (!isNaN(parseInt(value))){
|
||||||
|
db = parseInt(value, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { host: hostname, port: portInt, password, db };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createRetryStrategy() {
|
export function createRetryStrategy() {
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import { QueueName } from './constants';
|
|||||||
host: redisConfig.host,
|
host: redisConfig.host,
|
||||||
port: redisConfig.port,
|
port: redisConfig.port,
|
||||||
password: redisConfig.password,
|
password: redisConfig.password,
|
||||||
|
db: redisConfig.db,
|
||||||
retryStrategy: createRetryStrategy(),
|
retryStrategy: createRetryStrategy(),
|
||||||
},
|
},
|
||||||
defaultJobOptions: {
|
defaultJobOptions: {
|
||||||
|
|||||||
Reference in New Issue
Block a user