@hatchet-dev/typescript-sdk 1.32.0 → 1.33.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/package.json
CHANGED
|
@@ -23,6 +23,8 @@ export declare class HealthServer {
|
|
|
23
23
|
constructor(port: number, getStatus: () => WorkerStatus, workerName: string, getSlots: () => number, getActions: () => string[], getLabels: () => Record<string, string | number>, logger: Logger);
|
|
24
24
|
private handleRequest;
|
|
25
25
|
private handleHealth;
|
|
26
|
+
private handleReadyz;
|
|
27
|
+
private handleLivez;
|
|
26
28
|
private initializeMetrics;
|
|
27
29
|
private handleMetrics;
|
|
28
30
|
start(): Promise<void>;
|
|
@@ -40,6 +40,12 @@ class HealthServer {
|
|
|
40
40
|
if (url === '/health' && req.method === 'GET') {
|
|
41
41
|
yield this.handleHealth(res);
|
|
42
42
|
}
|
|
43
|
+
else if (url === '/readyz' && req.method === 'GET') {
|
|
44
|
+
this.handleReadyz(res);
|
|
45
|
+
}
|
|
46
|
+
else if (url === '/livez' && req.method === 'GET') {
|
|
47
|
+
this.handleLivez(res);
|
|
48
|
+
}
|
|
43
49
|
else if (url === '/metrics' && req.method === 'GET') {
|
|
44
50
|
yield this.handleMetrics(res);
|
|
45
51
|
}
|
|
@@ -59,10 +65,32 @@ class HealthServer {
|
|
|
59
65
|
labels: this.getLabels(),
|
|
60
66
|
nodeVersion: process.version,
|
|
61
67
|
};
|
|
68
|
+
// Always return 200 for compatibility with consumers that inspect the JSON
|
|
69
|
+
// status. Use /readyz when the HTTP status must indicate readiness.
|
|
62
70
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
63
71
|
yield res.end(JSON.stringify(response));
|
|
64
72
|
});
|
|
65
73
|
}
|
|
74
|
+
// Kubernetes-style readiness probe: 200 only when the worker is HEALTHY
|
|
75
|
+
// (registered and holding an action listener), 503 otherwise. Unlike
|
|
76
|
+
// /health, this is a plain status-code contract a vanilla `httpGet` probe
|
|
77
|
+
// can consume directly, with no body to parse.
|
|
78
|
+
handleReadyz(res) {
|
|
79
|
+
const ready = this.getStatus() === exports.workerStatus.HEALTHY;
|
|
80
|
+
res.writeHead(ready ? 200 : 503, { 'Content-Type': 'text/plain' });
|
|
81
|
+
res.end(ready ? 'ok' : 'not ready');
|
|
82
|
+
}
|
|
83
|
+
// Kubernetes-style liveness probe: 200 whenever this handler can run at
|
|
84
|
+
// all, deliberately independent of Hatchet connectivity. A worker that has
|
|
85
|
+
// temporarily lost its action listener (UNHEALTHY) should be pulled from
|
|
86
|
+
// rotation via /readyz, not killed and restarted via /livez — restarting
|
|
87
|
+
// does nothing to fix an upstream Hatchet outage and drops in-flight work.
|
|
88
|
+
// /livez only needs to fail when the process itself is deadlocked/wedged,
|
|
89
|
+
// which this HTTP response reaching the caller already disproves.
|
|
90
|
+
handleLivez(res) {
|
|
91
|
+
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
92
|
+
res.end('ok');
|
|
93
|
+
}
|
|
66
94
|
initializeMetrics() {
|
|
67
95
|
try {
|
|
68
96
|
// THIS IS AN OPTIONAL DEPENDENCY
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.33.0";
|
package/version.js
CHANGED