Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  health.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import type { GatewayBrowserClient } from "../gateway.ts";
import type { HealthSummary } from "../types.ts";

/** Default fallback returned when the gateway is unreachable or returns null. */
const HEALTH_FALLBACK: HealthSummary = {
  ok: false,
  ts: 0,
  durationMs: 0,
  heartbeatSeconds: 0,
  defaultAgentId: "",
  agents: [],
  sessions: { path: "", count: 0, recent: [] },
};

/** State slice consumed by {@link loadHealthState}. Follows the agents/sessions convention. */
export type HealthState = {
  client: GatewayBrowserClient | null;
  connected: boolean;
  healthLoading: boolean;
  healthResult: HealthSummary | null;
  healthError: string | null;
};

/**
 * Fetch the gateway health summary.
 *
 * Accepts a {@link GatewayBrowserClient} (matching the existing ui/ controller
 * convention).  Returns a fully-typed {@link HealthSummary}; on failure the
 * caller receives a safe fallback with `ok: false` rather than `null`.
 */
export async function loadHealth(client: GatewayBrowserClient): Promise<HealthSummary> {
  try {
    const result = await client.request<HealthSummary>("health", {});
    return result ?? HEALTH_FALLBACK;
  } catch {
    return HEALTH_FALLBACK;
  }
}

/**
 * State-mutating health loader (same pattern as {@link import("./agents.ts").loadAgents}).
 *
 * Populates `healthResult` / `healthError` on the provided state slice and
 * toggles `healthLoading` around the request.
 */
export async function loadHealthState(state: HealthState): Promise<void> {
  if (!state.client || !state.connected) {
    return;
  }
  if (state.healthLoading) {
    return;
  }
  state.healthLoading = true;
  state.healthError = null;
  try {
    state.healthResult = await loadHealth(state.client);
  } catch (err) {
    state.healthError = String(err);
  } finally {
    state.healthLoading = false;
  }
}

¤ Dauer der Verarbeitung: 0.21 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge