harperdb
Version:
HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.
90 lines (89 loc) • 3.42 kB
TypeScript
/**
* ComponentStatusRegistry Class
*
* This module contains the ComponentStatusRegistry class which provides
* centralized management of component health status.
*/
import { ComponentStatus } from './ComponentStatus.ts';
import { type ComponentStatusLevel, type AggregatedComponentStatus, type ComponentApplicationStatus } from './types.ts';
/**
* Map of component names to their status information
*/
export type ComponentStatusMap = Map<string, ComponentStatus>;
/**
* Component Status Registry Class
* Provides a centralized registry for managing component health status
*/
export declare class ComponentStatusRegistry {
private statusMap;
/**
* Reset the component status registry, clearing all existing status data
* This should be called when the component system starts up
*/
reset(): void;
/**
* Register or update component health status
* This function allows components to report their own health status
*/
setStatus(componentName: string, status: ComponentStatusLevel, message?: string, error?: Error | string): void;
/**
* Get the current status of a component
*/
getStatus(componentName: string): ComponentStatus | undefined;
/**
* Get all component statuses
*/
getAllStatuses(): ComponentStatusMap;
/**
* Report component as healthy
*/
reportHealthy(componentName: string, message?: string): void;
/**
* Report component error
*/
reportError(componentName: string, error: Error | string, message?: string): void;
/**
* Report component warning
*/
reportWarning(componentName: string, message: string): void;
/**
* Component Lifecycle Management
*/
/**
* Initialize component as loading - call this when component loading begins
*/
initializeLoading(componentName: string, message?: string): void;
/**
* Mark component as successfully loaded
*/
markLoaded(componentName: string, message?: string): void;
/**
* Mark component as failed to load
*/
markFailed(componentName: string, error: Error | string, message?: string): void;
/**
* Get all components with a specific status level
*/
getComponentsByStatus(statusLevel: ComponentStatusLevel): Array<{
name: string;
status: ComponentStatus;
}>;
/**
* Get a summary of all component statuses
*/
getStatusSummary(): Record<ComponentStatusLevel, number>;
/**
* Static method to get aggregated component statuses from all threads
* Returns a Map with one entry per component showing overall status and thread distribution
*/
static getAggregatedFromAllThreads(registry: ComponentStatusRegistry): Promise<Map<string, AggregatedComponentStatus>>;
/**
* Get aggregated status for a specific component and all its sub-components
* This method handles both exact matches and sub-component aggregation
*
* @param componentName - The component name to look up (e.g., "application-template", "http")
* @param consolidatedStatuses - Pre-fetched consolidated statuses from all threads (optional, will fetch if not provided)
* @returns Aggregated status information for the component
*/
getAggregatedStatusFor(componentName: string, consolidatedStatuses?: Map<string, AggregatedComponentStatus>): Promise<ComponentApplicationStatus>;
}