/// import { EventEmitter } from 'events'; import { MonitorResult, MonitorConfig, MonitorSubscription } from '../types'; import { PlatformAdapter } from '../types/platform'; import { CacheManager } from './cache-manager'; import { MonitorError } from '../types/errors'; /** * 基础监控器抽象类 * * 提供所有监控器的通用功能,包括缓存、事件、配置管理等 */ export declare abstract class BaseMonitor extends EventEmitter { protected config: MonitorConfig; protected adapter: PlatformAdapter; protected cache: CacheManager; protected subscriptions: Set; constructor(adapter: PlatformAdapter, config?: MonitorConfig, cache?: CacheManager); /** * 获取监控信息 */ abstract info(): Promise>; /** * 获取默认配置 */ protected abstract getDefaultConfig(): MonitorConfig; /** * 配置监控器 */ withConfig(config: Partial): this; /** * 配置缓存 */ withCaching(enabled: boolean, ttl?: number): this; /** * 实时监控 */ monitor(interval: number, callback: (data: T) => void): MonitorSubscription; /** * 获取配置 */ getConfig(): MonitorConfig; /** * 获取缓存统计 */ getCacheStats(): import("./cache-manager").CacheStats | null; /** * 清空缓存 */ clearCache(): void; /** * 停止所有监控订阅 */ stopAllMonitoring(): void; /** * 获取活跃订阅数量 */ getActiveSubscriptions(): number; /** * 销毁监控器 */ destroy(): void; /** * 获取缓存结果 */ protected getCachedResult(key: string): R | undefined; /** * 设置缓存结果 */ protected setCachedResult(key: string, result: R, ttl?: number): void; /** * 创建成功结果 */ protected createSuccessResult(data: R, cached?: boolean): MonitorResult; /** * 创建失败结果 */ protected createErrorResult(error: MonitorError): MonitorResult; /** * 处理错误并转换为 MonitorResult */ protected handleError(error: any): MonitorResult; /** * 执行带缓存的操作 */ protected executeWithCache(cacheKey: string, operation: () => Promise, ttl?: number): Promise>; /** * 验证平台支持 */ protected validatePlatformSupport(feature: string): void; /** * 创建不支持功能的错误 */ protected createUnsupportedError(feature: string): MonitorError; /** * 安全执行异步操作 */ protected safeExecute(operation: () => Promise, fallback?: R): Promise; /** * 创建超时 Promise */ protected createTimeoutPromise(timeoutMs: number, errorMessage?: string): Promise; /** * 带超时执行操作 */ protected executeWithTimeout(operation: () => Promise, timeoutMs?: number): Promise; } //# sourceMappingURL=base-monitor.d.ts.map