UNPKG

@ultipa-graph/ultipa-driver

Version:

NodeJS SDK for Ultipa GQL

51 lines (50 loc) 1.53 kB
/** * Health service handles health check operations. */ import { EventEmitter } from 'events'; import { ServiceContext } from './service-context'; import { HealthStatus } from '../types'; /** * Health watcher interface for streaming health updates. * Emits 'status' events with HealthStatus and 'error' events on failure. */ export interface HealthWatcher extends EventEmitter { /** Stop watching health updates */ stop(): void; } /** * Health service for checking service health. */ export declare class HealthService { private ctx; constructor(ctx: ServiceContext); /** * Check the health of a service. */ healthCheck(service?: string): Promise<HealthStatus>; /** * Watch health status changes via server-side streaming. * Returns a HealthWatcher that emits 'status' events with HealthStatus values. * Call stop() to cancel the stream. * * @param service - Optional service name to watch * @returns HealthWatcher - EventEmitter with stop() method * * @example * ```typescript * const watcher = healthService.watch(); * watcher.on('status', (status: HealthStatus) => { * console.log('Health status:', status); * }); * watcher.on('error', (err) => { * console.error('Watch error:', err); * }); * watcher.on('end', () => { * console.log('Watch stream ended'); * }); * // Later, to stop watching: * watcher.stop(); * ``` */ watch(service?: string): HealthWatcher; }