@qping/plugin-bus 0.9.0 → 0.10.0
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/bootstrap.mjs +0 -12
- package/dist/node.mjs +0 -12
- package/package.json +1 -1
- package/src/bootstrap.ts +0 -15
package/dist/bootstrap.mjs
CHANGED
|
@@ -426,21 +426,10 @@ async function runPlugin(handlers) {
|
|
|
426
426
|
const identity = await completeHandshake(transport, token);
|
|
427
427
|
const router = new HandlerRouter({ send: (env) => transport.send(env) });
|
|
428
428
|
router.setIdentity(identity);
|
|
429
|
-
const HOST_LOST_MS = 15e3;
|
|
430
|
-
let lastPingAt = Date.now();
|
|
431
|
-
const watchdog = setInterval(() => {
|
|
432
|
-
if (Date.now() - lastPingAt > HOST_LOST_MS) {
|
|
433
|
-
clearInterval(watchdog);
|
|
434
|
-
process.exit(1);
|
|
435
|
-
}
|
|
436
|
-
}, 1e3);
|
|
437
|
-
watchdog.unref?.();
|
|
438
429
|
transport.onDisconnect(() => {
|
|
439
|
-
clearInterval(watchdog);
|
|
440
430
|
process.exit(1);
|
|
441
431
|
});
|
|
442
432
|
transport.onMessage((env) => {
|
|
443
|
-
if (env.route === Routes.Bus.Ping) lastPingAt = Date.now();
|
|
444
433
|
router.dispatch(env);
|
|
445
434
|
});
|
|
446
435
|
for (const [route, handler] of Object.entries(handlers)) {
|
|
@@ -450,7 +439,6 @@ async function runPlugin(handlers) {
|
|
|
450
439
|
transport,
|
|
451
440
|
router,
|
|
452
441
|
close: async () => {
|
|
453
|
-
clearInterval(watchdog);
|
|
454
442
|
await transport.close();
|
|
455
443
|
}
|
|
456
444
|
};
|
package/dist/node.mjs
CHANGED
|
@@ -435,21 +435,10 @@ async function runPlugin(handlers) {
|
|
|
435
435
|
const identity = await completeHandshake(transport, token);
|
|
436
436
|
const router = new HandlerRouter({ send: (env) => transport.send(env) });
|
|
437
437
|
router.setIdentity(identity);
|
|
438
|
-
const HOST_LOST_MS = 15e3;
|
|
439
|
-
let lastPingAt = Date.now();
|
|
440
|
-
const watchdog = setInterval(() => {
|
|
441
|
-
if (Date.now() - lastPingAt > HOST_LOST_MS) {
|
|
442
|
-
clearInterval(watchdog);
|
|
443
|
-
process.exit(1);
|
|
444
|
-
}
|
|
445
|
-
}, 1e3);
|
|
446
|
-
watchdog.unref?.();
|
|
447
438
|
transport.onDisconnect(() => {
|
|
448
|
-
clearInterval(watchdog);
|
|
449
439
|
process.exit(1);
|
|
450
440
|
});
|
|
451
441
|
transport.onMessage((env) => {
|
|
452
|
-
if (env.route === Routes.Bus.Ping) lastPingAt = Date.now();
|
|
453
442
|
router.dispatch(env);
|
|
454
443
|
});
|
|
455
444
|
for (const [route, handler] of Object.entries(handlers)) {
|
|
@@ -459,7 +448,6 @@ async function runPlugin(handlers) {
|
|
|
459
448
|
transport,
|
|
460
449
|
router,
|
|
461
450
|
close: async () => {
|
|
462
|
-
clearInterval(watchdog);
|
|
463
451
|
await transport.close();
|
|
464
452
|
}
|
|
465
453
|
};
|
package/package.json
CHANGED
package/src/bootstrap.ts
CHANGED
|
@@ -46,25 +46,11 @@ export async function runPlugin(handlers: PluginHandlers): Promise<PluginRuntime
|
|
|
46
46
|
const router = new HandlerRouter({ send: (env: Envelope) => transport.send(env) });
|
|
47
47
|
router.setIdentity(identity);
|
|
48
48
|
|
|
49
|
-
// Passive host-liveness watchdog: exit if Host stops sending bus.ping (orphan process).
|
|
50
|
-
// Threshold is well above the host ping interval (~2s) to tolerate brief host stalls.
|
|
51
|
-
const HOST_LOST_MS = 15_000;
|
|
52
|
-
let lastPingAt = Date.now();
|
|
53
|
-
const watchdog = setInterval(() => {
|
|
54
|
-
if (Date.now() - lastPingAt > HOST_LOST_MS) {
|
|
55
|
-
clearInterval(watchdog);
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
}, 1_000);
|
|
59
|
-
watchdog.unref?.();
|
|
60
|
-
|
|
61
49
|
transport.onDisconnect(() => {
|
|
62
|
-
clearInterval(watchdog);
|
|
63
50
|
process.exit(1);
|
|
64
51
|
});
|
|
65
52
|
|
|
66
53
|
transport.onMessage((env) => {
|
|
67
|
-
if (env.route === Routes.Bus.Ping) lastPingAt = Date.now();
|
|
68
54
|
router.dispatch(env);
|
|
69
55
|
});
|
|
70
56
|
|
|
@@ -76,7 +62,6 @@ export async function runPlugin(handlers: PluginHandlers): Promise<PluginRuntime
|
|
|
76
62
|
transport,
|
|
77
63
|
router,
|
|
78
64
|
close: async () => {
|
|
79
|
-
clearInterval(watchdog);
|
|
80
65
|
await transport.close();
|
|
81
66
|
},
|
|
82
67
|
};
|