fix(core): Support redis cluster in queue mode (#6708)
* support redis cluster * cleanup, fix config schema * set default prefix to bull
This commit is contained in:
committed by
GitHub
parent
8ceb8322eb
commit
4029386349
@@ -199,4 +199,28 @@ export async function createErrorExecution(
|
||||
await Container.get(ExecutionRepository).createNewExecution(fullExecutionData);
|
||||
}
|
||||
|
||||
export function getRedisClusterNodes(): Array<{ host: string; port: number }> {
|
||||
const clusterNodePairs = config
|
||||
.getEnv('queue.bull.redis.clusterNodes')
|
||||
.split(',')
|
||||
.filter((e) => e);
|
||||
return clusterNodePairs.map((pair) => {
|
||||
const [host, port] = pair.split(':');
|
||||
return { host, port: parseInt(port) };
|
||||
});
|
||||
}
|
||||
|
||||
export function getRedisPrefix(): string {
|
||||
let prefix = config.getEnv('queue.bull.prefix');
|
||||
if (prefix && getRedisClusterNodes().length > 0) {
|
||||
if (!prefix.startsWith('{')) {
|
||||
prefix = '{' + prefix;
|
||||
}
|
||||
if (!prefix.endsWith('}')) {
|
||||
prefix += '}';
|
||||
}
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
export const DEFAULT_EXECUTIONS_GET_ALL_LIMIT = 20;
|
||||
|
||||
Reference in New Issue
Block a user