@diia-inhouse/workflow 3.4.24 → 3.4.26
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/services/worker.js
CHANGED
|
@@ -252,7 +252,7 @@ async function runWorker(app, options) {
|
|
|
252
252
|
});
|
|
253
253
|
const healthCheck = tryResolve(app.container, "healthCheck");
|
|
254
254
|
if (healthCheck) {
|
|
255
|
-
const workerHealthService = new WorkerHealthService();
|
|
255
|
+
const workerHealthService = new WorkerHealthService(Object.keys(instantiatedActivities).length > 0);
|
|
256
256
|
workerHealthService.setStatusProvider(() => worker.getStatus());
|
|
257
257
|
healthCheck.addHealthCheckable(workerHealthService);
|
|
258
258
|
}
|
|
@@ -7,7 +7,9 @@ interface WorkerHealthDetails {
|
|
|
7
7
|
worker: WorkerStatus | "NOT_INITIALIZED";
|
|
8
8
|
}
|
|
9
9
|
declare class WorkerHealthService implements OnHealthCheck {
|
|
10
|
+
private readonly hasActivities;
|
|
10
11
|
private statusProvider?;
|
|
12
|
+
constructor(hasActivities?: boolean);
|
|
11
13
|
setStatusProvider(provider: WorkerStatusProvider): void;
|
|
12
14
|
onHealthCheck(): Promise<HealthCheckResult<WorkerHealthDetails>>;
|
|
13
15
|
}
|
|
@@ -3,14 +3,18 @@ import { HttpStatusCode } from "@diia-inhouse/types";
|
|
|
3
3
|
function isPollerHealthy(state) {
|
|
4
4
|
return state === "POLLING";
|
|
5
5
|
}
|
|
6
|
-
function isWorkerHealthy(status) {
|
|
6
|
+
function isWorkerHealthy(status, hasActivities) {
|
|
7
7
|
const { runState, workflowPollerState, activityPollerState } = status;
|
|
8
8
|
if (runState !== "RUNNING") return false;
|
|
9
|
-
if (!isPollerHealthy(workflowPollerState)
|
|
10
|
-
return
|
|
9
|
+
if (!isPollerHealthy(workflowPollerState)) return false;
|
|
10
|
+
return !hasActivities || isPollerHealthy(activityPollerState);
|
|
11
11
|
}
|
|
12
12
|
var WorkerHealthService = class {
|
|
13
|
+
hasActivities;
|
|
13
14
|
statusProvider;
|
|
15
|
+
constructor(hasActivities = true) {
|
|
16
|
+
this.hasActivities = hasActivities;
|
|
17
|
+
}
|
|
14
18
|
setStatusProvider(provider) {
|
|
15
19
|
this.statusProvider = provider;
|
|
16
20
|
}
|
|
@@ -21,7 +25,7 @@ var WorkerHealthService = class {
|
|
|
21
25
|
};
|
|
22
26
|
const workerStatus = this.statusProvider();
|
|
23
27
|
return {
|
|
24
|
-
status: isWorkerHealthy(workerStatus) ? HttpStatusCode.OK : HttpStatusCode.SERVICE_UNAVAILABLE,
|
|
28
|
+
status: isWorkerHealthy(workerStatus, this.hasActivities) ? HttpStatusCode.OK : HttpStatusCode.SERVICE_UNAVAILABLE,
|
|
25
29
|
details: { worker: workerStatus }
|
|
26
30
|
};
|
|
27
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/workflow",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.26",
|
|
4
4
|
"description": "Workflow",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -107,15 +107,15 @@
|
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@diia-inhouse/configs": "7.2.1",
|
|
110
|
-
"@diia-inhouse/diia-logger": "4.5.
|
|
111
|
-
"@diia-inhouse/diia-metrics": "7.1.
|
|
112
|
-
"@diia-inhouse/diia-queue": "14.2.
|
|
113
|
-
"@diia-inhouse/env": "3.3.
|
|
114
|
-
"@diia-inhouse/healthcheck": "2.1.
|
|
115
|
-
"@diia-inhouse/oxc-config": "3.0.
|
|
116
|
-
"@diia-inhouse/test": "8.3.
|
|
117
|
-
"@diia-inhouse/types": "14.2.
|
|
118
|
-
"@diia-inhouse/utils": "6.1.
|
|
110
|
+
"@diia-inhouse/diia-logger": "4.5.2",
|
|
111
|
+
"@diia-inhouse/diia-metrics": "7.1.120",
|
|
112
|
+
"@diia-inhouse/diia-queue": "14.2.24",
|
|
113
|
+
"@diia-inhouse/env": "3.3.70",
|
|
114
|
+
"@diia-inhouse/healthcheck": "2.1.129",
|
|
115
|
+
"@diia-inhouse/oxc-config": "3.0.2",
|
|
116
|
+
"@diia-inhouse/test": "8.3.25",
|
|
117
|
+
"@diia-inhouse/types": "14.2.14",
|
|
118
|
+
"@diia-inhouse/utils": "6.1.13",
|
|
119
119
|
"@types/lodash": "4.17.24",
|
|
120
120
|
"@types/node": "26.1.0",
|
|
121
121
|
"@types/yargs": "17.0.35",
|