Skip to content

Commit

Permalink
refactor(core): Remove more dead code from event bus (no-changelog) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov authored Jun 11, 2024
1 parent 6ba789a commit c0e4f69
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 106 deletions.
102 changes: 0 additions & 102 deletions packages/cli/src/eventbus/EventMessageClasses/Helpers.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ import path, { parse } from 'path';
import { Worker } from 'worker_threads';
import { createReadStream, existsSync, rmSync } from 'fs';
import readline from 'readline';
import { jsonParse } from 'n8n-workflow';
import remove from 'lodash/remove';
import config from '@/config';
import { getEventMessageObjectByType } from '../EventMessageClasses/Helpers';
import type { EventMessageGenericOptions } from '../EventMessageClasses/EventMessageGeneric';
import { EventMessageGeneric } from '../EventMessageClasses/EventMessageGeneric';
import type { AbstractEventMessageOptions } from '../EventMessageClasses/AbstractEventMessageOptions';
import type { EventMessageWorkflowOptions } from '../EventMessageClasses/EventMessageWorkflow';
import { EventMessageWorkflow } from '../EventMessageClasses/EventMessageWorkflow';
import { EventMessageTypeNames, jsonParse } from 'n8n-workflow';
import type { EventMessageAuditOptions } from '../EventMessageClasses/EventMessageAudit';
import { EventMessageAudit } from '../EventMessageClasses/EventMessageAudit';
import type { EventMessageNodeOptions } from '../EventMessageClasses/EventMessageNode';
import { EventMessageNode } from '../EventMessageClasses/EventMessageNode';
import type { EventMessageReturnMode } from '../MessageEventBus/MessageEventBus';
import type { EventMessageTypes } from '../EventMessageClasses';
import type { EventMessageConfirmSource } from '../EventMessageClasses/EventMessageConfirm';
Expand Down Expand Up @@ -200,7 +208,7 @@ export class MessageEventBusLogWriter {
try {
const json = jsonParse(line);
if (isEventMessageOptions(json) && json.__type !== undefined) {
const msg = getEventMessageObjectByType(json);
const msg = this.getEventMessageObjectByType(json);
if (msg !== null) results.loggedMessages.push(msg);
if (msg?.eventName && msg.payload?.executionId) {
const executionId = msg.payload.executionId as string;
Expand Down Expand Up @@ -302,7 +310,7 @@ export class MessageEventBusLogWriter {
json.__type !== undefined &&
json.payload?.executionId === executionId
) {
const msg = getEventMessageObjectByType(json);
const msg = this.getEventMessageObjectByType(json);
if (msg !== null) messages.push(msg);
}
} catch {
Expand Down Expand Up @@ -346,4 +354,19 @@ export class MessageEventBusLogWriter {
unfinishedExecutions: result.unfinishedExecutions,
};
}

getEventMessageObjectByType(message: AbstractEventMessageOptions): EventMessageTypes | null {
switch (message.__type as EventMessageTypeNames) {
case EventMessageTypeNames.generic:
return new EventMessageGeneric(message as EventMessageGenericOptions);
case EventMessageTypeNames.workflow:
return new EventMessageWorkflow(message as EventMessageWorkflowOptions);
case EventMessageTypeNames.audit:
return new EventMessageAudit(message as EventMessageAuditOptions);
case EventMessageTypeNames.node:
return new EventMessageNode(message as EventMessageNodeOptions);
default:
return null;
}
}
}

0 comments on commit c0e4f69

Please sign in to comment.