mirror of
https://github.com/docmost/docmost.git
synced 2025-11-15 20:51:19 +10:00
feat: adding family 6 in uri to configure for both 4 and 6 (#807)
* feat: adding family 6 in uri to configure for both 4 and 6 * feat: adding redis family in websocket config
This commit is contained in:
committed by
GitHub
parent
7a47da9273
commit
6776e073b6
@ -20,11 +20,13 @@ export type RedisConfig = {
|
||||
port: number;
|
||||
db: number;
|
||||
password?: string;
|
||||
family?: number;
|
||||
};
|
||||
|
||||
export function parseRedisUrl(redisUrl: string): RedisConfig {
|
||||
// format - redis[s]://[[username][:password]@][host][:port][/db-number]
|
||||
const { hostname, port, password, pathname } = new URL(redisUrl);
|
||||
// format - redis[s]://[[username][:password]@][host][:port][/db-number][?family=4|6]
|
||||
const url = new URL(redisUrl);
|
||||
const { hostname, port, password, pathname, searchParams } = url;
|
||||
const portInt = parseInt(port, 10);
|
||||
|
||||
let db: number = 0;
|
||||
@ -36,7 +38,14 @@ export function parseRedisUrl(redisUrl: string): RedisConfig {
|
||||
}
|
||||
}
|
||||
|
||||
return { host: hostname, port: portInt, password, db };
|
||||
// extract family from query parameters
|
||||
let family: number | undefined;
|
||||
const familyParam = searchParams.get('family');
|
||||
if (familyParam && !isNaN(parseInt(familyParam))) {
|
||||
family = parseInt(familyParam, 10);
|
||||
}
|
||||
|
||||
return { host: hostname, port: portInt, password, db, family };
|
||||
}
|
||||
|
||||
export function createRetryStrategy() {
|
||||
|
||||
Reference in New Issue
Block a user