refactor(core): Have one orchestration service per instance type (#7303)

webhook instances will not listen to either worker or event log messages
on the Redis pub/sub channel
This commit is contained in:
Michael Auerswald
2023-10-06 13:58:11 +02:00
committed by GitHub
parent 193181a9c6
commit afa683a06f
25 changed files with 380 additions and 215 deletions

View File

@@ -0,0 +1,33 @@
import Container from 'typedi';
import type { WorkerCommandReceivedHandlerOptions } from './orchestration/worker/handleCommandMessageWorker';
import { RedisService } from './redis.service';
import type { RedisServicePubSubSubscriber } from './redis/RedisServicePubSubSubscriber';
export abstract class OrchestrationHandlerService {
protected initialized = false;
redisSubscriber: RedisServicePubSubSubscriber;
readonly redisService: RedisService;
constructor() {
this.redisService = Container.get(RedisService);
}
async init() {
await this.initSubscriber();
this.initialized = true;
}
async initWithOptions(options: WorkerCommandReceivedHandlerOptions) {
await this.initSubscriber(options);
this.initialized = true;
}
async shutdown() {
await this.redisSubscriber?.destroy();
this.initialized = false;
}
protected abstract initSubscriber(options?: WorkerCommandReceivedHandlerOptions): Promise<void>;
}