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:
committed by
GitHub
parent
193181a9c6
commit
afa683a06f
@@ -0,0 +1,6 @@
|
||||
import { handleCommandMessageMain } from '../main/handleCommandMessageMain';
|
||||
|
||||
export async function handleCommandMessageWebhook(messageString: string) {
|
||||
// currently webhooks handle commands the same way as the main instance
|
||||
return handleCommandMessageMain(messageString);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { Service } from 'typedi';
|
||||
import { COMMAND_REDIS_CHANNEL } from '../../redis/RedisServiceHelper';
|
||||
import { OrchestrationHandlerService } from '../../orchestration.handler.base.service';
|
||||
import { handleCommandMessageWebhook } from './handleCommandMessageWebhook';
|
||||
|
||||
@Service()
|
||||
export class OrchestrationHandlerWebhookService extends OrchestrationHandlerService {
|
||||
async initSubscriber() {
|
||||
this.redisSubscriber = await this.redisService.getPubSubSubscriber();
|
||||
|
||||
await this.redisSubscriber.subscribeToCommandChannel();
|
||||
|
||||
this.redisSubscriber.addMessageHandler(
|
||||
'OrchestrationMessageReceiver',
|
||||
async (channel: string, messageString: string) => {
|
||||
if (channel === COMMAND_REDIS_CHANNEL) {
|
||||
await handleCommandMessageWebhook(messageString);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Service } from 'typedi';
|
||||
import { OrchestrationService } from '../../orchestration.base.service';
|
||||
|
||||
@Service()
|
||||
export class OrchestrationWebhookService extends OrchestrationService {
|
||||
sanityCheck(): boolean {
|
||||
return this.initialized && this.isQueueMode && this.isWebhookInstance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user