mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(core): Have one orchestration service per instance type (#7303)
webhook instances will not listen to either worker or event log messages on the Redis pub/sub channel
This commit is contained in:
committed by
GitHub
parent
193181a9c6
commit
afa683a06f
@@ -2,6 +2,10 @@ import { LoggerProxy, jsonParse } from 'n8n-workflow';
|
||||
import type { RedisServiceCommandObject } from '../redis/RedisServiceCommands';
|
||||
import { COMMAND_REDIS_CHANNEL } from '../redis/RedisServiceHelper';
|
||||
|
||||
export interface RedisServiceCommandLastReceived {
|
||||
[date: string]: Date;
|
||||
}
|
||||
|
||||
export function messageToRedisServiceCommandObject(messageString: string) {
|
||||
if (!messageString) return;
|
||||
let message: RedisServiceCommandObject;
|
||||
@@ -15,3 +19,15 @@ export function messageToRedisServiceCommandObject(messageString: string) {
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
const lastReceived: RedisServiceCommandLastReceived = {};
|
||||
|
||||
export function debounceMessageReceiver(message: RedisServiceCommandObject, timeout: number = 100) {
|
||||
const now = new Date();
|
||||
const lastReceivedDate = lastReceived[message.command];
|
||||
if (lastReceivedDate && now.getTime() - lastReceivedDate.getTime() < timeout) {
|
||||
return false;
|
||||
}
|
||||
lastReceived[message.command] = now;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user