Skip to main content

apps/gateway/src/services/worker-runtime-repository.ts

Metadata

Indexed Symbols

  • normalizeStatus (line 17, function) - Implements normalize status for service-layer operations.
  • normalizeDetails (line 21, function) - Implements normalize details for service-layer operations.
  • heartbeatWorker (line 25, function) - Implements heartbeat worker for service-layer operations.
  • listWorkerRuntimeStatus (line 41, function) - Implements list worker runtime status for service-layer operations.

Markdown Headings (if applicable)

No markdown headings detected.

Source Preview

import { query } from "./postgres.js";

export type WorkerRuntimeStatus = {
workerName: string;
status: "healthy" | "degraded";
lastSeenAt: string;
details: Record<string, unknown>;
};

type WorkerRuntimeStatusRow = {
worker_name: string;
status: string;
last_seen_at: string;
details: unknown;
};

function normalizeStatus(value: string): "healthy" | "degraded" {
return value === "degraded" ? "degraded" : "healthy";
}

function normalizeDetails(input: unknown): Record<string, unknown> {
return typeof input === "object" && input !== null ? (input as Record<string, unknown>) : {};
}

export async function heartbeatWorker(