@sailboat-computer/event-bus
Version:
Standardized event bus for sailboat computer v3 with resilience features and offline capabilities
131 lines • 3.13 kB
TypeScript
/**
* Event bus monitoring and alerting
*/
import { Alert, AlertHandler, AlertType, ExtendedEventBusMetrics } from './types';
/**
* Alert manager for event bus monitoring
*/
export declare class AlertManager {
/**
* Alert handlers
*/
private handlers;
/**
* Active alerts
*/
private activeAlerts;
/**
* Alert history
*/
private alertHistory;
/**
* Maximum number of alerts to keep in history
*/
private maxHistorySize;
/**
* Alert thresholds
*/
private thresholds;
/**
* Create a new alert manager
*
* @param thresholds - Alert thresholds
*/
constructor(thresholds?: {
failedPublishesThreshold?: number;
deadLetterQueueSizeThreshold?: number;
reconnectionAttemptsThreshold?: number;
processingTimeThreshold?: number;
});
/**
* Register an alert handler
*
* @param handler - Alert handler
* @returns Handler ID
*/
registerHandler(handler: AlertHandler): string;
/**
* Unregister an alert handler
*
* @param handlerId - Handler ID
*/
unregisterHandler(handlerId: string): void;
/**
* Check metrics for alerts
*
* @param metrics - Event bus metrics
*/
checkMetrics(metrics: ExtendedEventBusMetrics): void;
/**
* Check connection status
*
* @param connected - Whether the adapter is connected
*/
checkConnectionStatus(connected: boolean): void;
/**
* Create or update an alert
*
* @param type - Alert type
* @param severity - Alert severity
* @param message - Alert message
* @param details - Alert details
*/
private createOrUpdateAlert;
/**
* Resolve an alert
*
* @param type - Alert type
*/
private resolveAlert;
/**
* Get active alert by type
*
* @param type - Alert type
* @returns Alert or undefined
*/
private getActiveAlertByType;
/**
* Add alert to history
*
* @param alert - Alert
*/
private addToHistory;
/**
* Notify handlers of an alert
*
* @param alert - Alert
*/
private notifyHandlers;
/**
* Get active alerts
*
* @param type - Optional alert type to filter by
* @returns Active alerts
*/
getActiveAlerts(type?: AlertType): Alert[];
/**
* Get alert history
*
* @param limit - Maximum number of alerts to return
* @param type - Optional alert type to filter by
* @returns Alert history
*/
getAlertHistory(limit?: number, type?: AlertType): Alert[];
/**
* Clear alert history
*/
clearAlertHistory(): void;
}
/**
* Create a new alert manager
*
* @param thresholds - Alert thresholds
* @returns Alert manager
*/
export declare function createAlertManager(thresholds?: {
failedPublishesThreshold?: number;
deadLetterQueueSizeThreshold?: number;
reconnectionAttemptsThreshold?: number;
processingTimeThreshold?: number;
}): AlertManager;
//# sourceMappingURL=monitoring.d.ts.map