Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): Remove more dead code from event bus (no-changelog) #9697

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
}
Loading