StatusWorkerClient

Sending heartbeats to the internal Lunar status worker from lunar-js, including recurring heartbeats and introspection calls.

StatusWorkerClient

StatusWorkerClient talks to the internal Lunar status worker — the heartbeat monitor that relays component health to the hep.gg status page. Services send a heartbeat with their current status; if a component goes silent for 30 seconds the worker opens an outage incident, and the next heartbeat resolves it.

import { StatusWorkerClient } from 'lunar-js';
 
const status = new StatusWorkerClient(); // defaults to http://127.0.0.1:3030
 
// One-off heartbeat:
await status.heartbeat('lunar-api'); // status defaults to 'operational'
await status.heartbeat('lunar-api', 'degraded');
 
// Recurring heartbeat (sends immediately, then every 10s by default):
const beat = status.startHeartbeat('lunar-api', {
    getStatus: () => (dbHealthy ? 'operational' : 'degraded'), // optional, may be async
});
// ...on shutdown:
beat.stop();
 
// Introspection:
await status.health();                // all component states
await status.componentHealth('lunar-api');
await status.diag();                  // worker config + live hep.gg round-trip

Valid statuses are operational, degraded, partial, outage, and maintenance (exported as the ComponentStatus type and COMPONENT_STATUSES list).