mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
* support redis cluster * cleanup, fix config schema * set default prefix to bull * initial commit * improve logging * improve types and refactor * list support and refactor * fix redis service and tests * add comment * add redis and cache prefix * use injection * lint fix * clean schema comments * improve naming, tests, cluster client * merge master * cache returns unknown instead of T * update cache service, tests and doc * remove console.log * do not cache null or undefined values * fix merge * lint fix
31 lines
950 B
TypeScript
31 lines
950 B
TypeScript
import { Service } from 'typedi';
|
|
import { WORKER_RESPONSE_REDIS_LIST } from './RedisServiceHelper';
|
|
import type { RedisServiceWorkerResponseObject } from './RedisServiceCommands';
|
|
import { RedisServiceBaseSender } from './RedisServiceBaseClasses';
|
|
|
|
@Service()
|
|
export class RedisServiceListSender extends RedisServiceBaseSender {
|
|
async init(senderId?: string): Promise<void> {
|
|
await super.init('list-sender');
|
|
this.setSenderId(senderId);
|
|
}
|
|
|
|
async prepend(list: string, message: string): Promise<void> {
|
|
if (!this.redisClient) {
|
|
await this.init();
|
|
}
|
|
await this.redisClient?.lpush(list, message);
|
|
}
|
|
|
|
async append(list: string, message: string): Promise<void> {
|
|
if (!this.redisClient) {
|
|
await this.init();
|
|
}
|
|
await this.redisClient?.rpush(list, message);
|
|
}
|
|
|
|
async appendWorkerResponse(message: RedisServiceWorkerResponseObject): Promise<void> {
|
|
await this.prepend(WORKER_RESPONSE_REDIS_LIST, JSON.stringify(message));
|
|
}
|
|
}
|