@diia-inhouse/workflow 3.4.24 → 3.4.25

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.
@@ -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) || !isPollerHealthy(activityPollerState)) return false;
10
- return true;
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.24",
3
+ "version": "3.4.25",
4
4
  "description": "Workflow",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",