Files
n8n-enterprise-unlocked/packages/cli/src/services/redis/RedisServiceListSender.ts
Michael Auerswald 3cad60e918 feat(core): Make Redis available for backend communication (#6719)
* 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
2023-08-02 12:51:25 +02:00

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));
}
}