n8n
Version:
n8n Workflow Automation Tool
32 lines (31 loc) • 1.79 kB
TypeScript
import { TaskRunnersConfig } from '@n8n/config';
import type { BrokerMessage } from '@n8n/task-runner';
import { Logger } from 'n8n-core';
import type WebSocket from 'ws';
import { WsStatusCodes } from '../constants';
import { DefaultTaskRunnerDisconnectAnalyzer } from './default-task-runner-disconnect-analyzer';
import { TaskBroker, type TaskRunner } from './task-broker.service';
import { TaskRunnerLifecycleEvents } from './task-runner-lifecycle-events';
import type { DisconnectAnalyzer, DisconnectReason, TaskRunnerServerInitRequest, TaskRunnerServerInitResponse } from './task-runner-types';
type WsStatusCode = (typeof WsStatusCodes)[keyof typeof WsStatusCodes];
export declare class TaskRunnerWsServer {
private readonly logger;
private readonly taskBroker;
private disconnectAnalyzer;
private readonly taskTunnersConfig;
private readonly runnerLifecycleEvents;
runnerConnections: Map<TaskRunner['id'], WebSocket>;
private heartbeatTimer;
constructor(logger: Logger, taskBroker: TaskBroker, disconnectAnalyzer: DefaultTaskRunnerDisconnectAnalyzer, taskTunnersConfig: TaskRunnersConfig, runnerLifecycleEvents: TaskRunnerLifecycleEvents);
start(): void;
private startHeartbeatChecks;
stop(): Promise<void>;
setDisconnectAnalyzer(disconnectAnalyzer: DisconnectAnalyzer): void;
getDisconnectAnalyzer(): DefaultTaskRunnerDisconnectAnalyzer;
sendMessage(id: TaskRunner['id'], message: BrokerMessage.ToRunner.All): void;
add(id: TaskRunner['id'], connection: WebSocket): void;
removeConnection(id: TaskRunner['id'], reason?: DisconnectReason, code?: WsStatusCode): Promise<void>;
handleRequest(req: TaskRunnerServerInitRequest, _res: TaskRunnerServerInitResponse): void;
private stopConnectedRunners;
}
export {};