backend: Refactor RedisService to use dependency injection for LoggerService
This commit is contained in:
parent
d0d4c90821
commit
89b8b699ee
@ -1,4 +1,4 @@
|
|||||||
import { injectable } from '../config/dependency-injector.config.js';
|
import { inject, injectable } from '../config/dependency-injector.config.js';
|
||||||
import * as config from '../environment.js';
|
import * as config from '../environment.js';
|
||||||
import { Redis, RedisOptions, SentinelAddress } from 'ioredis';
|
import { Redis, RedisOptions, SentinelAddress } from 'ioredis';
|
||||||
import {
|
import {
|
||||||
@ -17,14 +17,13 @@ import { EventEmitter } from 'events';
|
|||||||
import Redlock from 'redlock';
|
import Redlock from 'redlock';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class RedisService extends LoggerService {
|
export class RedisService {
|
||||||
protected readonly DEFAULT_TTL: number = 32 * 60 * 60 * 24; // 32 days
|
protected readonly DEFAULT_TTL: number = 32 * 60 * 60 * 24; // 32 days
|
||||||
protected redis: Redis;
|
protected redis: Redis;
|
||||||
protected isConnected = false;
|
protected isConnected = false;
|
||||||
public events: EventEmitter;
|
public events: EventEmitter;
|
||||||
|
|
||||||
constructor() {
|
constructor(@inject(LoggerService) protected logger: LoggerService) {
|
||||||
super();
|
|
||||||
this.events = new EventEmitter();
|
this.events = new EventEmitter();
|
||||||
const redisOptions = this.loadRedisConfig();
|
const redisOptions = this.loadRedisConfig();
|
||||||
this.redis = new Redis(redisOptions);
|
this.redis = new Redis(redisOptions);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user