mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Introduce RedisClientService (no-changelog) (#9774)
This commit is contained in:
@@ -3,7 +3,7 @@ import type { Cluster } from 'ioredis';
|
||||
import { Service } from 'typedi';
|
||||
import config from '@/config';
|
||||
import { Logger } from '@/Logger';
|
||||
import { getDefaultRedisClient } from './RedisServiceHelper';
|
||||
import { RedisClientService } from './redis-client.service';
|
||||
|
||||
export type RedisClientType =
|
||||
| 'subscriber'
|
||||
@@ -29,13 +29,16 @@ class RedisServiceBase {
|
||||
|
||||
isInitialized = false;
|
||||
|
||||
constructor(protected readonly logger: Logger) {}
|
||||
constructor(
|
||||
protected readonly logger: Logger,
|
||||
private readonly redisClientService: RedisClientService,
|
||||
) {}
|
||||
|
||||
async init(type: RedisClientType = 'client'): Promise<void> {
|
||||
if (this.redisClient && this.isInitialized) {
|
||||
return;
|
||||
}
|
||||
this.redisClient = await getDefaultRedisClient(undefined, type);
|
||||
this.redisClient = this.redisClientService.createClient({ type });
|
||||
|
||||
this.redisClient.on('close', () => {
|
||||
this.logger.warn('Redis unavailable - trying to reconnect...');
|
||||
|
||||
Reference in New Issue
Block a user