refactor(core): Refactor WorkflowStatistics code (no-changelog) (#6617)

refactor(core): Refactor WorkflowStatistics code
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-07-18 11:28:24 +02:00
committed by GitHub
parent e7091d6726
commit f4a18ba87d
20 changed files with 432 additions and 571 deletions

View File

@@ -1,3 +1,4 @@
import { EventEmitter } from 'events';
import { ServerResponse } from 'http';
import type { Server } from 'http';
import type { Socket } from 'net';
@@ -16,7 +17,7 @@ import type { IPushDataType } from '@/Interfaces';
const useWebSockets = config.getEnv('push.backend') === 'websocket';
@Service()
export class Push {
export class Push extends EventEmitter {
private backend = useWebSockets ? new WebSocketPush() : new SSEPush();
handleRequest(req: SSEPushRequest | WebSocketPushRequest, res: PushResponse) {
@@ -27,6 +28,7 @@ export class Push {
} else {
res.status(401).send('Unauthorized');
}
this.emit('editorUiConnected', req.query.sessionId);
}
send<D>(type: IPushDataType, data: D, sessionId: string | undefined = undefined) {