@camstack/system 1.2.429 → 1.2.431
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/dist/builtins/calendars/calendars.addon.js +1 -1
- package/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/composer/composer.addon.js +2 -2
- package/dist/builtins/composer/composer.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
- package/dist/builtins/device-manager/device-manager.addon.js +2 -2
- package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +3 -3
- package/dist/builtins/keychain/index.mjs +3 -3
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/dist/builtins/local-network/local-network.addon.js +1 -1
- package/dist/builtins/local-network/local-network.addon.mjs +1 -1
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/file-host-client.d.ts +11 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/index.js +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +34 -4
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +34 -4
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +74 -10
- package/dist/builtins/system-config/system-config.addon.mjs +74 -11
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-SYtYuAgh.mjs → composition-sources-Cw_TXEq9.mjs} +1 -1
- package/dist/{composition-sources-C2VNX6tF.js → composition-sources-o5MPSlk6.js} +1 -1
- package/dist/{constants-RI-hGP5S.js → constants-BcNaVkvI.js} +1 -1
- package/dist/{constants-CKuWoWvc.mjs → constants-CttE77VF.mjs} +1 -1
- package/dist/{device-ca-R7DKKZL6.mjs → device-ca-B-BTxeCj.mjs} +1 -1
- package/dist/{device-ca-BWfdDB3k.js → device-ca-CKiqh2Iu.js} +1 -1
- package/dist/{dist-CSSfTM18.mjs → dist-CXG6muCR.mjs} +545 -34
- package/dist/{dist-Bgy_AmwX.js → dist-DxJdci75.js} +545 -34
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/index.js +203 -53
- package/dist/index.mjs +198 -55
- package/dist/kernel/index.d.ts +4 -2
- package/dist/kernel/moleculer/broker-factory.d.ts +28 -2
- package/dist/kernel/moleculer/broker-transport-swap.d.ts +43 -0
- package/dist/kernel/moleculer/mesh-mtls/mesh-certificate-registry.d.ts +10 -0
- package/dist/kernel/moleculer/mesh-mtls/mesh-peer-transport.d.ts +7 -3
- package/dist/kernel/moleculer/mesh-mtls/mesh-renewal.d.ts +8 -1
- package/dist/{restore-archive-BYUEMsog.js → restore-archive-CQJNoqRK.js} +1 -1
- package/dist/{restore-archive-AIwMHO5_.mjs → restore-archive-D_wBL1OO.mjs} +1 -1
- package/dist/{retired-settings-keys-H0rYXT27.mjs → retired-settings-keys-EmDe11cP.mjs} +1 -1
- package/dist/{retired-settings-keys-BTPkRLTS.js → retired-settings-keys-g1oifXxR.js} +1 -1
- package/dist/{wal-maintenance-BSGsxKW7.js → wal-maintenance-BW1LIHi0.js} +0 -0
- package/dist/{wal-maintenance-DW0FfGV7.mjs → wal-maintenance-vhPZLYuA.mjs} +0 -0
- package/package.json +2 -2
package/dist/file-host-worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Cek0wNdY.js");
|
|
2
|
-
const require_wal_maintenance = require("./wal-maintenance-
|
|
2
|
+
const require_wal_maintenance = require("./wal-maintenance-BW1LIHi0.js");
|
|
3
3
|
let node_worker_threads = require("node:worker_threads");
|
|
4
4
|
//#region src/builtins/sqlite-storage/file-host-worker.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as callControl, E as controlTargetOf, T as callVector, _ as collectTransferables, a as WalMaintenance, b as isFileHostWorkerData, c as SqliteSettingsBackend, h as serializeError, o as createVectorIndex, s as vectorProviderOf, w as callData, x as trustInput, y as isFileHostRequest } from "./wal-maintenance-
|
|
1
|
+
import { C as callControl, E as controlTargetOf, T as callVector, _ as collectTransferables, a as WalMaintenance, b as isFileHostWorkerData, c as SqliteSettingsBackend, h as serializeError, o as createVectorIndex, s as vectorProviderOf, w as callData, x as trustInput, y as isFileHostRequest } from "./wal-maintenance-vhPZLYuA.mjs";
|
|
2
2
|
import { parentPort, threadId, workerData } from "node:worker_threads";
|
|
3
3
|
//#region src/builtins/sqlite-storage/file-host-worker.ts
|
|
4
4
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("./chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("./dist-
|
|
4
|
-
const require_device_ca = require("./device-ca-
|
|
3
|
+
const require_dist = require("./dist-DxJdci75.js");
|
|
4
|
+
const require_device_ca = require("./device-ca-CKiqh2Iu.js");
|
|
5
5
|
const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
|
|
6
6
|
require("./builtins/alerts/index.js");
|
|
7
7
|
const require_builtins_calendars_calendars_addon = require("./builtins/calendars/calendars.addon.js");
|
|
@@ -22,13 +22,13 @@ require("./builtins/local-auth/index.js");
|
|
|
22
22
|
const require_builtins_loki_logging_index = require("./builtins/loki-logging/index.js");
|
|
23
23
|
const require_builtins_native_metrics_native_metrics_addon = require("./builtins/native-metrics/native-metrics.addon.js");
|
|
24
24
|
const require_builtins_sqlite_storage_filesystem_storage_addon = require("./builtins/sqlite-storage/filesystem-storage.addon.js");
|
|
25
|
-
const require_wal_maintenance = require("./wal-maintenance-
|
|
25
|
+
const require_wal_maintenance = require("./wal-maintenance-BW1LIHi0.js");
|
|
26
26
|
const require_builtins_sqlite_storage_sqlite_settings_addon = require("./builtins/sqlite-storage/sqlite-settings.addon.js");
|
|
27
27
|
const require_builtins_sqlite_storage_index = require("./builtins/sqlite-storage/index.js");
|
|
28
28
|
const require_builtins_storage_orchestrator_storage_orchestrator_addon = require("./builtins/storage-orchestrator/storage-orchestrator.addon.js");
|
|
29
29
|
require("./builtins/storage-orchestrator/index.js");
|
|
30
30
|
const require_agent_https_names = require("./agent-https-names-CpUSuP4w.js");
|
|
31
|
-
const require_constants = require("./constants-
|
|
31
|
+
const require_constants = require("./constants-BcNaVkvI.js");
|
|
32
32
|
const require_builtins_system_config_system_config_addon = require("./builtins/system-config/system-config.addon.js");
|
|
33
33
|
require("./builtins/system-config/index.js");
|
|
34
34
|
const require_builtins_winston_logging_index = require("./builtins/winston-logging/index.js");
|
|
@@ -36,7 +36,7 @@ const require_custom_action_registry = require("./custom-action-registry-Bf_Ynag
|
|
|
36
36
|
const require_tls = require("./tls-C5IYg3V5.js");
|
|
37
37
|
const require_platform_key_source = require("./platform-key-source-Di7HrlGR.js");
|
|
38
38
|
const require_resource_monitor = require("./resource-monitor-mio9dSCT.js");
|
|
39
|
-
const require_restore_archive = require("./restore-archive-
|
|
39
|
+
const require_restore_archive = require("./restore-archive-CQJNoqRK.js");
|
|
40
40
|
let zod = require("zod");
|
|
41
41
|
let node_crypto = require("node:crypto");
|
|
42
42
|
node_crypto = require_chunk.__toESM(node_crypto);
|
|
@@ -15054,7 +15054,7 @@ function resolveUseHostname() {
|
|
|
15054
15054
|
return process.env["CAMSTACK_MOLECULER_USE_HOSTNAME"] !== "false";
|
|
15055
15055
|
}
|
|
15056
15056
|
function createBroker(config) {
|
|
15057
|
-
const { nodeID, mode,
|
|
15057
|
+
const { nodeID, mode, logLevel = "warn", tcpPort = DEFAULT_HUB_TCP_PORT } = config;
|
|
15058
15058
|
const useHostname = resolveUseHostname();
|
|
15059
15059
|
const infraLevel = "error";
|
|
15060
15060
|
const wildcardLevel = logLevel;
|
|
@@ -15101,56 +15101,11 @@ function createBroker(config) {
|
|
|
15101
15101
|
},
|
|
15102
15102
|
metrics: metricsConfig
|
|
15103
15103
|
});
|
|
15104
|
-
const
|
|
15105
|
-
const hasMeshTls = config.meshTls !== void 0;
|
|
15106
|
-
const hubDialPort = hasMeshTls ? config.tlsPort ?? 6443 : tcpPort;
|
|
15107
|
-
if (hasMeshTls) {
|
|
15108
|
-
const urls = hubAddress !== void 0 ? normalizeHubUrl(hubAddress, hubDialPort) : void 0;
|
|
15109
|
-
return new require_builtins_system_config_system_config_addon.ServiceBroker({
|
|
15110
|
-
nodeID,
|
|
15111
|
-
serializer: "MsgPack",
|
|
15112
|
-
transporter: new require_builtins_system_config_system_config_addon.TlsTcpTransporter({
|
|
15113
|
-
port: agentListenPort,
|
|
15114
|
-
tlsPort: config.agentTlsListenPort ?? 6443,
|
|
15115
|
-
peerTlsPort: hubDialPort,
|
|
15116
|
-
hubOnlyPeers: true,
|
|
15117
|
-
maxPacketSize: 10 * 1024 * 1024,
|
|
15118
|
-
useHostname,
|
|
15119
|
-
debug: false,
|
|
15120
|
-
meshTls: config.meshTls,
|
|
15121
|
-
udpDiscovery: false,
|
|
15122
|
-
...urls !== void 0 ? { urls } : {}
|
|
15123
|
-
}),
|
|
15124
|
-
...config.middlewares !== void 0 ? { middlewares: [...config.middlewares] } : {},
|
|
15125
|
-
logger: {
|
|
15126
|
-
type: "Console",
|
|
15127
|
-
options: { level: {
|
|
15128
|
-
BROKER: infraLevel,
|
|
15129
|
-
TRANSPORTER: infraLevel,
|
|
15130
|
-
TRANSIT: infraLevel,
|
|
15131
|
-
REGISTRY: infraLevel,
|
|
15132
|
-
DISCOVERER: infraLevel,
|
|
15133
|
-
"**": wildcardLevel
|
|
15134
|
-
} }
|
|
15135
|
-
},
|
|
15136
|
-
metrics: metricsConfig
|
|
15137
|
-
});
|
|
15138
|
-
}
|
|
15139
|
-
const tcpOptions = {
|
|
15140
|
-
maxPacketSize: 10 * 1024 * 1024,
|
|
15141
|
-
port: agentListenPort,
|
|
15142
|
-
useHostname,
|
|
15143
|
-
debug: false
|
|
15144
|
-
};
|
|
15145
|
-
tcpOptions.udpDiscovery = false;
|
|
15146
|
-
if (hubAddress) tcpOptions.urls = normalizeHubUrl(hubAddress, tcpPort);
|
|
15104
|
+
const transport = createAgentTransport(config);
|
|
15147
15105
|
return new require_builtins_system_config_system_config_addon.ServiceBroker({
|
|
15148
15106
|
nodeID,
|
|
15149
15107
|
serializer: "MsgPack",
|
|
15150
|
-
transporter:
|
|
15151
|
-
type: "TCP",
|
|
15152
|
-
options: tcpOptions
|
|
15153
|
-
},
|
|
15108
|
+
transporter: transport.kind === "tls" ? transport.transporter : transport.descriptor,
|
|
15154
15109
|
...config.middlewares !== void 0 ? { middlewares: [...config.middlewares] } : {},
|
|
15155
15110
|
logger: {
|
|
15156
15111
|
type: "Console",
|
|
@@ -15166,6 +15121,58 @@ function createBroker(config) {
|
|
|
15166
15121
|
metrics: metricsConfig
|
|
15167
15122
|
});
|
|
15168
15123
|
}
|
|
15124
|
+
/**
|
|
15125
|
+
* The transport of an agent broker, from its config. An agent with no hub address dials nobody
|
|
15126
|
+
* and stays `unconfigured` until one is set (the agent UI lists the hubs found over mDNS, D839).
|
|
15127
|
+
* There is no UDP discovery to fall back on (D843).
|
|
15128
|
+
*
|
|
15129
|
+
* The reader binds a STABLE port derived from the nodeID (not an OS-ephemeral `port: 0`). See
|
|
15130
|
+
* `deriveAgentListenPort` - this is what makes a same-nodeID kill+restart reconnect cleanly:
|
|
15131
|
+
* Moleculer never refreshes a known node's address, so the agent must return at the same address
|
|
15132
|
+
* it left from.
|
|
15133
|
+
*
|
|
15134
|
+
* Shared by `createBroker` (the first transport) and the in-place reconnect
|
|
15135
|
+
* (`broker-transport-swap.ts`, the next one): one builder, so a reconnect cannot dial differently
|
|
15136
|
+
* from a boot.
|
|
15137
|
+
*/
|
|
15138
|
+
function createAgentTransport(config) {
|
|
15139
|
+
const { nodeID, hubAddress, tcpPort = DEFAULT_HUB_TCP_PORT } = config;
|
|
15140
|
+
const useHostname = resolveUseHostname();
|
|
15141
|
+
const agentListenPort = config.agentListenPort ?? deriveAgentListenPort(nodeID);
|
|
15142
|
+
const hubDialPort = config.meshTls !== void 0 ? config.tlsPort ?? 6443 : tcpPort;
|
|
15143
|
+
if (config.meshTls !== void 0) {
|
|
15144
|
+
const urls = hubAddress !== void 0 ? normalizeHubUrl(hubAddress, hubDialPort) : void 0;
|
|
15145
|
+
return {
|
|
15146
|
+
kind: "tls",
|
|
15147
|
+
transporter: new require_builtins_system_config_system_config_addon.TlsTcpTransporter({
|
|
15148
|
+
port: agentListenPort,
|
|
15149
|
+
tlsPort: config.agentTlsListenPort ?? 6443,
|
|
15150
|
+
peerTlsPort: hubDialPort,
|
|
15151
|
+
hubOnlyPeers: true,
|
|
15152
|
+
maxPacketSize: 10 * 1024 * 1024,
|
|
15153
|
+
useHostname,
|
|
15154
|
+
debug: false,
|
|
15155
|
+
meshTls: config.meshTls,
|
|
15156
|
+
udpDiscovery: false,
|
|
15157
|
+
...urls !== void 0 ? { urls } : {}
|
|
15158
|
+
})
|
|
15159
|
+
};
|
|
15160
|
+
}
|
|
15161
|
+
return {
|
|
15162
|
+
kind: "tcp",
|
|
15163
|
+
descriptor: {
|
|
15164
|
+
type: "TCP",
|
|
15165
|
+
options: {
|
|
15166
|
+
maxPacketSize: 10 * 1024 * 1024,
|
|
15167
|
+
port: agentListenPort,
|
|
15168
|
+
useHostname,
|
|
15169
|
+
debug: false,
|
|
15170
|
+
udpDiscovery: false,
|
|
15171
|
+
...hubAddress ? { urls: normalizeHubUrl(hubAddress, tcpPort) } : {}
|
|
15172
|
+
}
|
|
15173
|
+
}
|
|
15174
|
+
};
|
|
15175
|
+
}
|
|
15169
15176
|
function normalizeHubUrl(raw, defaultPort) {
|
|
15170
15177
|
const atSplit = raw.includes("@") ? raw.split("@") : null;
|
|
15171
15178
|
const nodeIdFromAt = atSplit ? atSplit[0] : null;
|
|
@@ -15181,6 +15188,142 @@ function getBrokerTlsTransporter(broker) {
|
|
|
15181
15188
|
return tx instanceof require_builtins_system_config_system_config_addon.TlsTcpTransporter ? tx : null;
|
|
15182
15189
|
}
|
|
15183
15190
|
//#endregion
|
|
15191
|
+
//#region src/kernel/moleculer/broker-transport-swap.ts
|
|
15192
|
+
/**
|
|
15193
|
+
* Reconnecting a broker's TRANSPORT in place, without rebuilding the broker (D856 amendment).
|
|
15194
|
+
*
|
|
15195
|
+
* An agent changes how it dials the hub (a new hub address, a new cluster secret, a mesh leaf
|
|
15196
|
+
* swap or its rollback) by replacing its transporter. It used to stop the whole `ServiceBroker`
|
|
15197
|
+
* and build another. That threw away everything bound to the old one: the `$process` service
|
|
15198
|
+
* (whose `stopped()` SIGTERMs every runner - the "child gone" lines), `$agent-cap-fwd`,
|
|
15199
|
+
* `$agent`, the event bus, the addon services and every closure that captured the broker. The
|
|
15200
|
+
* node came back ONLINE and capless, and the hub's confirm step then failed with
|
|
15201
|
+
* "`$agent-cap-fwd.forward` is not found".
|
|
15202
|
+
*
|
|
15203
|
+
* The broker, its services, its registries and its child runners are all independent of the
|
|
15204
|
+
* wire. So only the wire is replaced: disconnect the transit, forget the remote nodes (their
|
|
15205
|
+
* connection is gone, and the next `$node.connected` is what re-runs the mesh join), install a
|
|
15206
|
+
* new transporter on the SAME transit and connect it. Children never notice; the join's settle
|
|
15207
|
+
* re-sends the full manifest (D3), which still carries every child.
|
|
15208
|
+
*/
|
|
15209
|
+
function isObject(value) {
|
|
15210
|
+
return typeof value === "object" && value !== null;
|
|
15211
|
+
}
|
|
15212
|
+
function isFunction(value) {
|
|
15213
|
+
return typeof value === "function";
|
|
15214
|
+
}
|
|
15215
|
+
/** Moleculer's d.ts hides the transit and the registry internals: check them at runtime instead. */
|
|
15216
|
+
function isWrappingBroker(value) {
|
|
15217
|
+
return isObject(value) && isFunction(Reflect.get(value, "wrapMethod")) && hasNodeCatalog(Reflect.get(value, "registry")) && "transit" in value;
|
|
15218
|
+
}
|
|
15219
|
+
/** The node catalog the swap forgets remote nodes through (private Moleculer API, pinned by a spec). */
|
|
15220
|
+
function hasNodeCatalog(registry) {
|
|
15221
|
+
if (!isObject(registry)) return false;
|
|
15222
|
+
const nodes = Reflect.get(registry, "nodes");
|
|
15223
|
+
return isObject(nodes) && isFunction(Reflect.get(nodes, "disconnected")) && isFunction(Reflect.get(nodes, "list"));
|
|
15224
|
+
}
|
|
15225
|
+
function isTransporterLike(value) {
|
|
15226
|
+
return isObject(value) && isFunction(Reflect.get(value, "init")) && isFunction(Reflect.get(value, "connect")) && isFunction(Reflect.get(value, "disconnect"));
|
|
15227
|
+
}
|
|
15228
|
+
function wrapping(broker) {
|
|
15229
|
+
if (!isWrappingBroker(broker)) throw new Error("not a Moleculer broker with a transport");
|
|
15230
|
+
return broker;
|
|
15231
|
+
}
|
|
15232
|
+
function transitOf(broker) {
|
|
15233
|
+
const transit = wrapping(broker).transit;
|
|
15234
|
+
if (transit === null || transit === void 0) throw new Error("the broker has no transport to reconnect");
|
|
15235
|
+
return transit;
|
|
15236
|
+
}
|
|
15237
|
+
/** The transporter currently installed on the broker (for identity checks). */
|
|
15238
|
+
function currentBrokerTransporter(broker) {
|
|
15239
|
+
return { tx: transitOf(broker).tx };
|
|
15240
|
+
}
|
|
15241
|
+
/** Build the transporter an {@link AgentTransport} describes (nothing is bound or dialled yet). */
|
|
15242
|
+
function buildTransporter(transport) {
|
|
15243
|
+
const tx = transport.kind === "tls" ? transport.transporter : require_builtins_system_config_system_config_addon.Transporters.resolve(transport.descriptor);
|
|
15244
|
+
if (!isTransporterLike(tx)) throw new Error("the agent transport is not a Moleculer transporter");
|
|
15245
|
+
return { tx };
|
|
15246
|
+
}
|
|
15247
|
+
/**
|
|
15248
|
+
* Whether `pending` is the transporter installed on the broker right now. A reconnect that was
|
|
15249
|
+
* abandoned at its deadline and resumes later must not tear down a newer run's transport.
|
|
15250
|
+
*/
|
|
15251
|
+
function isInstalledTransporter(broker, pending) {
|
|
15252
|
+
return transitOf(broker).tx === pending.tx;
|
|
15253
|
+
}
|
|
15254
|
+
/**
|
|
15255
|
+
* Disconnect the installed transporter and forget every remote node. Forgetting is what makes the
|
|
15256
|
+
* hub's next INFO a NEW connection: `$node.connected` fires again, so the agent's mesh join re-runs
|
|
15257
|
+
* and its settle re-sends the manifest. Without it the hub would still be "available" in the local
|
|
15258
|
+
* registry and nothing would re-announce the node.
|
|
15259
|
+
*/
|
|
15260
|
+
async function disconnectBrokerTransport(broker) {
|
|
15261
|
+
const b = wrapping(broker);
|
|
15262
|
+
const transit = transitOf(broker);
|
|
15263
|
+
const leaving = transit.tx;
|
|
15264
|
+
retired.add(leaving);
|
|
15265
|
+
try {
|
|
15266
|
+
await transit.disconnect();
|
|
15267
|
+
} finally {
|
|
15268
|
+
detachListeners(leaving);
|
|
15269
|
+
for (const node of b.registry.nodes.list({ onlyAvailable: true })) if (node.id !== b.nodeID) b.registry.nodes.disconnected(node.id, false);
|
|
15270
|
+
}
|
|
15271
|
+
}
|
|
15272
|
+
/** Transporters that were disconnected or replaced: their `connect` is a no-op for good. */
|
|
15273
|
+
var retired = /* @__PURE__ */ new WeakSet();
|
|
15274
|
+
/**
|
|
15275
|
+
* The leaving transporter's writer must not keep reporting into the SHARED node catalog: a late
|
|
15276
|
+
* FIN on one of its sockets would call `nodes.disconnected` on the node the NEW transporter just
|
|
15277
|
+
* connected to.
|
|
15278
|
+
*/
|
|
15279
|
+
function detachListeners(tx) {
|
|
15280
|
+
for (const emitter of [tx.writer, tx.reader]) if (isObject(emitter) && isFunction(Reflect.get(emitter, "removeAllListeners"))) Reflect.get(emitter, "removeAllListeners").call(emitter);
|
|
15281
|
+
}
|
|
15282
|
+
/**
|
|
15283
|
+
* One connect at a time per transporter, and none for a retired or replaced one. Moleculer's connect
|
|
15284
|
+
* retry re-runs `tx.connect()` on whatever `transit.tx` is when its timer fires; a second run of
|
|
15285
|
+
* `startTcpServer` overwrites the live reader and writer, leaks the gossip interval and leaves a
|
|
15286
|
+
* listening server behind. A connect that fails is cleaned up before the retry runs.
|
|
15287
|
+
*/
|
|
15288
|
+
function guardConnect(transit, tx) {
|
|
15289
|
+
const original = tx.connect.bind(tx);
|
|
15290
|
+
let inflight = null;
|
|
15291
|
+
tx.connect = (...args) => {
|
|
15292
|
+
if (retired.has(tx) || transit.tx !== tx) return Promise.resolve();
|
|
15293
|
+
if (inflight !== null) return inflight;
|
|
15294
|
+
if (tx.connected === true) return Promise.resolve();
|
|
15295
|
+
const run = original(...args).catch(async (error) => {
|
|
15296
|
+
await Promise.resolve(tx.disconnect()).catch(() => void 0);
|
|
15297
|
+
throw error;
|
|
15298
|
+
}).finally(() => {
|
|
15299
|
+
if (inflight === run) inflight = null;
|
|
15300
|
+
});
|
|
15301
|
+
inflight = run;
|
|
15302
|
+
return run;
|
|
15303
|
+
};
|
|
15304
|
+
}
|
|
15305
|
+
/**
|
|
15306
|
+
* Install `pending` as the broker's transporter: the same wiring Moleculer's `Transit` constructor
|
|
15307
|
+
* does (init + the broker's send/receive middleware wrapping, which carries the mesh join gate).
|
|
15308
|
+
*/
|
|
15309
|
+
function installBrokerTransporter(broker, pending) {
|
|
15310
|
+
const b = wrapping(broker);
|
|
15311
|
+
const transit = transitOf(broker);
|
|
15312
|
+
const tx = pending.tx;
|
|
15313
|
+
retired.add(transit.tx);
|
|
15314
|
+
guardConnect(transit, tx);
|
|
15315
|
+
tx.init(transit, (cmd, packet) => transit.messageHandler(cmd, packet), transit.afterConnect.bind(transit));
|
|
15316
|
+
const send = b.wrapMethod("transporterSend", tx.send, tx);
|
|
15317
|
+
const receive = b.wrapMethod("transporterReceive", tx.receive, tx, { reverse: true });
|
|
15318
|
+
tx.send = send;
|
|
15319
|
+
tx.receive = receive;
|
|
15320
|
+
transit.tx = tx;
|
|
15321
|
+
}
|
|
15322
|
+
/** Connect the installed transporter (the broker's own `start()` path, minus the services). */
|
|
15323
|
+
async function connectBrokerTransport(broker) {
|
|
15324
|
+
await transitOf(broker).connect();
|
|
15325
|
+
}
|
|
15326
|
+
//#endregion
|
|
15184
15327
|
//#region src/kernel/moleculer/addon-deploy-source.ts
|
|
15185
15328
|
function isAddonDeploySource(v) {
|
|
15186
15329
|
if (!v || typeof v !== "object") return false;
|
|
@@ -27144,6 +27287,7 @@ exports.buildNativeCapProxy = buildNativeCapProxy;
|
|
|
27144
27287
|
exports.buildNodeManifest = buildNodeManifest;
|
|
27145
27288
|
exports.buildNpmChildEnv = buildNpmChildEnv;
|
|
27146
27289
|
exports.buildStorageLocationRegistry = require_builtins_storage_orchestrator_storage_orchestrator_addon.buildStorageLocationRegistry;
|
|
27290
|
+
exports.buildTransporter = buildTransporter;
|
|
27147
27291
|
exports.builderMountedCapNames = builderMountedCapNames;
|
|
27148
27292
|
exports.caFingerprint = require_builtins_system_config_system_config_addon.caFingerprint;
|
|
27149
27293
|
exports.caFingerprintCompact = require_builtins_system_config_system_config_addon.caFingerprintCompact;
|
|
@@ -27170,6 +27314,7 @@ exports.collectCertIdentity = require_tls.collectCertIdentity;
|
|
|
27170
27314
|
exports.collectModelFiles = require_custom_action_registry.collectModelFiles;
|
|
27171
27315
|
exports.computeHubJoinProof = computeHubJoinProof;
|
|
27172
27316
|
exports.computeNodeJoinProof = computeNodeJoinProof;
|
|
27317
|
+
exports.connectBrokerTransport = connectBrokerTransport;
|
|
27173
27318
|
exports.contentTypeFor = require_custom_action_registry.contentTypeFor;
|
|
27174
27319
|
exports.copyDirRecursive = copyDirRecursive;
|
|
27175
27320
|
exports.copyExtraFileDirs = copyExtraFileDirs;
|
|
@@ -27179,6 +27324,7 @@ exports.createAddonPeerBytesFacility = createAddonPeerBytesFacility;
|
|
|
27179
27324
|
exports.createAddonService = createAddonService;
|
|
27180
27325
|
exports.createAgentEventScope = createAgentEventScope;
|
|
27181
27326
|
exports.createAgentHttpsRequest = require_tls.createAgentHttpsRequest;
|
|
27327
|
+
exports.createAgentTransport = createAgentTransport;
|
|
27182
27328
|
exports.createArrayBufferCensusGate = createArrayBufferCensusGate;
|
|
27183
27329
|
exports.createAuthenticatedFileServer = require_custom_action_registry.createAuthenticatedFileServer;
|
|
27184
27330
|
exports.createBroker = createBroker;
|
|
@@ -27217,6 +27363,7 @@ exports.createUdsEventBus = createUdsEventBus;
|
|
|
27217
27363
|
exports.createUdsLogger = createUdsLogger;
|
|
27218
27364
|
exports.createUdsLoggerWithControl = createUdsLoggerWithControl;
|
|
27219
27365
|
exports.createV8Reclaimer = createV8Reclaimer;
|
|
27366
|
+
exports.currentBrokerTransporter = currentBrokerTransporter;
|
|
27220
27367
|
exports.decideMeshAutoEnforce = decideMeshAutoEnforce;
|
|
27221
27368
|
exports.deleteModelFromDisk = require_custom_action_registry.deleteModelFromDisk;
|
|
27222
27369
|
exports.deriveAgentListenPort = deriveAgentListenPort;
|
|
@@ -27230,6 +27377,7 @@ exports.deviceOfGetStatus = deviceOfGetStatus;
|
|
|
27230
27377
|
exports.diffCapActionCensus = diffCapActionCensus;
|
|
27231
27378
|
exports.diffEventPlane = diffEventPlane;
|
|
27232
27379
|
exports.diffSocketPlane = diffSocketPlane;
|
|
27380
|
+
exports.disconnectBrokerTransport = disconnectBrokerTransport;
|
|
27233
27381
|
Object.defineProperty(exports, "downloadBinary", {
|
|
27234
27382
|
enumerable: true,
|
|
27235
27383
|
get: function() {
|
|
@@ -27337,6 +27485,7 @@ exports.heapSpaceField = heapSpaceField;
|
|
|
27337
27485
|
exports.hostNodeIdOf = hostNodeIdOf;
|
|
27338
27486
|
exports.hubMainRssBudget = hubMainRssBudget;
|
|
27339
27487
|
exports.installAgentHttps = require_tls.installAgentHttps;
|
|
27488
|
+
exports.installBrokerTransporter = installBrokerTransporter;
|
|
27340
27489
|
exports.installManifestNativeDeps = installManifestNativeDeps;
|
|
27341
27490
|
exports.installManifestPythonDeps = installManifestPythonDeps;
|
|
27342
27491
|
exports.installManifestSystemDeps = installManifestSystemDeps;
|
|
@@ -27363,6 +27512,7 @@ exports.isCollectionArrayMethod = require_dist.isCollectionArrayMethod;
|
|
|
27363
27512
|
exports.isContainerBridgeAddress = require_tls.isContainerBridgeAddress;
|
|
27364
27513
|
exports.isCredentialKeyName = isCredentialKeyName;
|
|
27365
27514
|
exports.isInfraCapability = isInfraCapability;
|
|
27515
|
+
exports.isInstalledTransporter = isInstalledTransporter;
|
|
27366
27516
|
exports.isLocalOnlyHostname = require_tls.isLocalOnlyHostname;
|
|
27367
27517
|
exports.isMeshAuthMode = require_builtins_system_config_system_config_addon.isMeshAuthMode;
|
|
27368
27518
|
exports.isModelDownloaded = require_custom_action_registry.isModelDownloaded;
|