refactoring continuing
This commit is contained in:
parent
742e590382
commit
a0a3b26177
20 changed files with 394 additions and 798 deletions
9
libs/data/cache/src/connection-manager.ts
vendored
9
libs/data/cache/src/connection-manager.ts
vendored
|
|
@ -1,5 +1,4 @@
|
|||
import Redis from 'ioredis';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { RedisConfig } from './types';
|
||||
|
||||
interface ConnectionConfig {
|
||||
|
|
@ -7,6 +6,7 @@ interface ConnectionConfig {
|
|||
singleton?: boolean;
|
||||
db?: number;
|
||||
redisConfig: RedisConfig;
|
||||
logger?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -16,7 +16,7 @@ export class RedisConnectionManager {
|
|||
private connections = new Map<string, Redis>();
|
||||
private static sharedConnections = new Map<string, Redis>();
|
||||
private static instance: RedisConnectionManager;
|
||||
private logger = getLogger('redis-connection-manager');
|
||||
private logger: any = console;
|
||||
private static readyConnections = new Set<string>();
|
||||
|
||||
// Singleton pattern for the manager itself
|
||||
|
|
@ -33,7 +33,10 @@ export class RedisConnectionManager {
|
|||
* @returns Redis connection instance
|
||||
*/
|
||||
getConnection(config: ConnectionConfig): Redis {
|
||||
const { name, singleton = false, db, redisConfig } = config;
|
||||
const { name, singleton = false, db, redisConfig, logger } = config;
|
||||
if (logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
if (singleton) {
|
||||
// Use shared connection across all instances
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue