@zudojs/runtime 1.0.0 → 1.1.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.
|
@@ -53,10 +53,23 @@ export class ReadinessTracker {
|
|
|
53
53
|
removeCheck(name) {
|
|
54
54
|
const existed = this.checks.delete(name);
|
|
55
55
|
this.checkFns.delete(name);
|
|
56
|
-
if (existed) {
|
|
56
|
+
if (!existed) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (this.autoMarkReady &&
|
|
60
|
+
this.checks.size === 0 &&
|
|
61
|
+
this.state === "degraded") {
|
|
62
|
+
// `degraded` is only ever entered from `ready` because a check
|
|
63
|
+
// failed. Removing the last check leaves nothing failing, so the
|
|
64
|
+
// tracker returns to ready — otherwise `evaluateReadiness()` (which
|
|
65
|
+
// only acts when checks exist) left it stuck at `ready: false` while
|
|
66
|
+
// the derived health, seeing no checks, reported `healthy`.
|
|
67
|
+
this.markReady("All readiness checks removed.");
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
57
70
|
this.evaluateReadiness();
|
|
58
71
|
}
|
|
59
|
-
return
|
|
72
|
+
return true;
|
|
60
73
|
}
|
|
61
74
|
/**
|
|
62
75
|
* Evaluates a readiness check and records its result.
|
|
@@ -206,6 +206,17 @@ export class DefaultRuntime {
|
|
|
206
206
|
if (this.stopPromise) {
|
|
207
207
|
return this.stopPromise;
|
|
208
208
|
}
|
|
209
|
+
if (this.startPromise) {
|
|
210
|
+
// A stop requested while startup is in flight — typically a SIGTERM
|
|
211
|
+
// arriving while modules are still coming up — waits for startup to
|
|
212
|
+
// settle and then shuts down whatever it produced. Previously this
|
|
213
|
+
// threw `RuntimeStateError` ("cannot stop a runtime in state
|
|
214
|
+
// initializing"), so the signal handler logged "Shutdown failed" and
|
|
215
|
+
// the runtime carried on to `running` as if nothing had happened.
|
|
216
|
+
// Startup is bounded by `startupTimeout`, so this wait is too.
|
|
217
|
+
await this.startPromise.catch(() => undefined);
|
|
218
|
+
return this.stop();
|
|
219
|
+
}
|
|
209
220
|
if (this._state === "created") {
|
|
210
221
|
this._state = "stopped";
|
|
211
222
|
this._stoppedAt = new Date();
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ResolvedRuntimeOptions } from "./runtimeOptions.type.js";
|
|
2
2
|
/**
|
|
3
3
|
* Resolves runtime options with defaults applied.
|
|
4
|
+
*
|
|
5
|
+
* `runtimeId` is documented as "auto-generated if not provided", but until
|
|
6
|
+
* this generated one nothing did: `DEFAULT_RUNTIME_OPTIONS` has no entry
|
|
7
|
+
* for it, so an omitted id reached every event payload, log line and
|
|
8
|
+
* `runtime.context.runtimeId` as `undefined`.
|
|
4
9
|
*/
|
|
5
10
|
export declare function resolveRuntimeOptions(options: ResolvedRuntimeOptions): ResolvedRuntimeOptions;
|
|
6
11
|
/**
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { DEFAULT_RUNTIME_OPTIONS } from "./runtimeOptions.type.js";
|
|
2
|
+
import { createRuntimeId } from "../runtimeContext/runtimeContext.factory.js";
|
|
2
3
|
/**
|
|
3
4
|
* Resolves runtime options with defaults applied.
|
|
5
|
+
*
|
|
6
|
+
* `runtimeId` is documented as "auto-generated if not provided", but until
|
|
7
|
+
* this generated one nothing did: `DEFAULT_RUNTIME_OPTIONS` has no entry
|
|
8
|
+
* for it, so an omitted id reached every event payload, log line and
|
|
9
|
+
* `runtime.context.runtimeId` as `undefined`.
|
|
4
10
|
*/
|
|
5
11
|
export function resolveRuntimeOptions(options) {
|
|
6
12
|
// Spreading `options` wholesale lets an explicitly-undefined key erase
|
|
@@ -9,6 +15,7 @@ export function resolveRuntimeOptions(options) {
|
|
|
9
15
|
const provided = Object.fromEntries(Object.entries(options ?? {}).filter(([, value]) => value !== undefined));
|
|
10
16
|
return Object.freeze({
|
|
11
17
|
...DEFAULT_RUNTIME_OPTIONS,
|
|
18
|
+
runtimeId: createRuntimeId(),
|
|
12
19
|
...provided,
|
|
13
20
|
});
|
|
14
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zudojs/runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Application lifecycle orchestrator with dependency ordering, rollback, signals, and readiness checks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,15 +27,19 @@
|
|
|
27
27
|
"vitest": "^4.1.11"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@zudojs/errors": "1.0.
|
|
31
|
-
"@zudojs/constants": "1.0.
|
|
32
|
-
"@zudojs/container": "1.
|
|
33
|
-
"@zudojs/config": "1.0.
|
|
34
|
-
"@zudojs/logger": "1.
|
|
35
|
-
"@zudojs/events": "1.0.
|
|
36
|
-
"@zudojs/core": "1.
|
|
30
|
+
"@zudojs/errors": "1.0.1",
|
|
31
|
+
"@zudojs/constants": "1.0.1",
|
|
32
|
+
"@zudojs/container": "1.1.0",
|
|
33
|
+
"@zudojs/config": "1.0.1",
|
|
34
|
+
"@zudojs/logger": "1.1.0",
|
|
35
|
+
"@zudojs/events": "1.0.1",
|
|
36
|
+
"@zudojs/core": "1.1.0"
|
|
37
37
|
},
|
|
38
38
|
"license": "MIT",
|
|
39
|
+
"author": {
|
|
40
|
+
"name": "Oluwayemi Oyinlola",
|
|
41
|
+
"url": "https://github.com/oyinlola-tech"
|
|
42
|
+
},
|
|
39
43
|
"publishConfig": {
|
|
40
44
|
"access": "public"
|
|
41
45
|
},
|