UNPKG

harperdb

Version:

HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.

105 lines (104 loc) 3.16 kB
/** * Component Status Public API * * This module provides the clean, simple public API for component status tracking. * All internal implementation details are hidden behind this interface. */ import { ComponentStatus } from './ComponentStatus.ts'; /** * Component Status Builder * Provides a fluent interface for reporting component status */ export declare class ComponentStatusBuilder { private componentName; constructor(componentName: string); /** * Report component as healthy * @param message Optional status message * @returns this for chaining */ healthy(message?: string): this; /** * Report component warning * @param message Warning message (required for warnings) * @returns this for chaining */ warning(message: string): this; /** * Report component error * @param message Error message * @param error Optional error object for additional context * @returns this for chaining */ error(message: string, error?: Error): this; /** * Report component as loading * @param message Optional loading message * @returns this for chaining */ loading(message?: string): this; /** * Report component status as unknown * @param message Optional message explaining why status is unknown * @returns this for chaining */ unknown(message?: string): this; /** * Get the current status of this component * @returns Current component status or undefined if not set */ get(): ComponentStatus | undefined; } /** * Get a status builder for a component * This is the primary API for reporting component status * * @example * ```typescript * // Report status * statusForComponent('my-service').healthy('Service started'); * statusForComponent('database').error('Connection failed', err); * statusForComponent('cache').warning('Memory usage high'); * * // Get status * const status = statusForComponent('my-service').get(); * ``` */ export declare function statusForComponent(name: string): ComponentStatusBuilder; /** * Component lifecycle hooks for internal use * These are used by the component loader */ export declare const lifecycle: { /** * Mark component as starting to load */ loading(componentName: string, message?: string): void; /** * Mark component as successfully loaded */ loaded(componentName: string, message?: string): void; /** * Mark component as failed to load */ failed(componentName: string, error: Error | string, message?: string): void; }; /** * Reset all component statuses (useful for testing) */ export declare function reset(): void; /** * Status level constants for external use */ export declare const STATUS: { readonly HEALTHY: "healthy"; readonly WARNING: "warning"; readonly ERROR: "error"; readonly UNKNOWN: "unknown"; readonly LOADING: "loading"; }; /** * Re-export only the types that external users need */ export type { ComponentStatusLevel, AggregatedComponentStatus } from './types.ts'; export type { ComponentStatus } from './ComponentStatus.ts';