mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(core): Make orchestration service smaller (#11275)
This commit is contained in:
@@ -12,6 +12,7 @@ import config from '@/config';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { OnShutdown } from '@/decorators/on-shutdown';
|
||||
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||
import { Publisher } from '@/scaling/pubsub/publisher.service';
|
||||
import { OrchestrationService } from '@/services/orchestration.service';
|
||||
import { TypedEmitter } from '@/typed-emitter';
|
||||
|
||||
@@ -39,7 +40,10 @@ export class Push extends TypedEmitter<PushEvents> {
|
||||
|
||||
private backend = useWebSockets ? Container.get(WebSocketPush) : Container.get(SSEPush);
|
||||
|
||||
constructor(private readonly orchestrationService: OrchestrationService) {
|
||||
constructor(
|
||||
private readonly orchestrationService: OrchestrationService,
|
||||
private readonly publisher: Publisher,
|
||||
) {
|
||||
super();
|
||||
|
||||
if (useWebSockets) this.backend.on('message', (msg) => this.emit('message', msg));
|
||||
@@ -89,8 +93,10 @@ export class Push extends TypedEmitter<PushEvents> {
|
||||
* relay the former's execution lifecycle events to the creator's frontend.
|
||||
*/
|
||||
if (this.orchestrationService.isMultiMainSetupEnabled && !this.backend.hasPushRef(pushRef)) {
|
||||
const payload = { type, args: data, pushRef };
|
||||
void this.orchestrationService.publish('relay-execution-lifecycle-event', payload);
|
||||
void this.publisher.publishCommand({
|
||||
command: 'relay-execution-lifecycle-event',
|
||||
payload: { type, args: data, pushRef },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user