refactor(core): Implement a new OnPubSubEvent decorator (#15688)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2025-06-04 18:32:33 +02:00
committed by GitHub
parent b772462cea
commit 4b11268a6e
38 changed files with 610 additions and 1153 deletions

View File

@@ -1,7 +1,7 @@
import type { PushMessage } from '@n8n/api-types';
import { inProduction, Logger } from '@n8n/backend-common';
import type { User } from '@n8n/db';
import { OnShutdown } from '@n8n/decorators';
import { OnPubSubEvent, OnShutdown } from '@n8n/decorators';
import { Container, Service } from '@n8n/di';
import type { Application } from 'express';
import { ServerResponse } from 'http';
@@ -205,6 +205,12 @@ export class Push extends TypedEmitter<PushEvents> {
return isWorker || (isMultiMain && !this.hasPushRef(pushRef));
}
@OnPubSubEvent('relay-execution-lifecycle-event', { instanceType: 'main' })
handleRelayExecutionLifecycleEvent({ pushRef, ...pushMsg }: PushMessage & { pushRef: string }) {
if (!this.hasPushRef(pushRef)) return;
this.send(pushMsg, pushRef);
}
/**
* Relay a push message via the `n8n.commands` pubsub channel,
* reducing the payload size if too large.