mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 20:29:08 +00:00
refactor(core): Move queueModeId as hostId to InstanceSettings (#11262)
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import { createHash, randomBytes } from 'crypto';
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
||||
import { ApplicationError, jsonParse } from 'n8n-workflow';
|
||||
import { ApplicationError, jsonParse, ALPHABET } from 'n8n-workflow';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import path from 'path';
|
||||
import { Service } from 'typedi';
|
||||
|
||||
const nanoid = customAlphabet(ALPHABET, 16);
|
||||
|
||||
interface ReadOnlySettings {
|
||||
encryptionKey: string;
|
||||
}
|
||||
@@ -40,6 +43,12 @@ export class InstanceSettings {
|
||||
|
||||
private settings = this.loadOrCreate();
|
||||
|
||||
/**
|
||||
* Fixed ID of this n8n instance, for telemetry.
|
||||
* Derived from encryption key. Do not confuse with `hostId`.
|
||||
*
|
||||
* @example '258fce876abf5ea60eb86a2e777e5e190ff8f3e36b5b37aafec6636c31d4d1f9'
|
||||
*/
|
||||
readonly instanceId = this.generateInstanceId();
|
||||
|
||||
readonly instanceType: InstanceType;
|
||||
@@ -49,6 +58,8 @@ export class InstanceSettings {
|
||||
this.instanceType = ['webhook', 'worker'].includes(command)
|
||||
? (command as InstanceType)
|
||||
: 'main';
|
||||
|
||||
this.hostId = `${this.instanceType}-${nanoid()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,6 +72,16 @@ export class InstanceSettings {
|
||||
*/
|
||||
instanceRole: InstanceRole = 'unset';
|
||||
|
||||
/**
|
||||
* Transient ID of this n8n instance, for scaling mode.
|
||||
* Reset on restart. Do not confuse with `instanceId`.
|
||||
*
|
||||
* @example 'main-bnxa1riryKUNHtln'
|
||||
* @example 'worker-nDJR0FnSd2Vf6DB5'
|
||||
* @example 'webhook-jxQ7AO8IzxEtfW1F'
|
||||
*/
|
||||
readonly hostId: string;
|
||||
|
||||
get isLeader() {
|
||||
return this.instanceRole === 'leader';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user