UNPKG

@wioex/stream-sdk

Version:

WebSocket streaming SDK for real-time WioEX market data

87 lines 2.19 kB
/** * Error Queue - Batched Error Reporting with Rate Limiting * * Optimizes error reporting by: * 1. Batching multiple errors together * 2. Rate limiting duplicate errors * 3. Deduplicating similar errors * 4. Backpressure handling */ import type { ErrorReportPayload } from '../types.js'; /** * Error queue configuration */ export interface ErrorQueueConfig { /** Maximum batch size before auto-flush */ maxBatchSize?: number; /** Flush interval in milliseconds */ flushInterval?: number; /** Enable error deduplication */ deduplication?: boolean; /** Deduplication window in milliseconds */ deduplicationWindow?: number; /** Maximum queue size (prevent memory leaks) */ maxQueueSize?: number; } /** * ErrorQueue class for batched and rate-limited error reporting */ export declare class ErrorQueue { private readonly sendBatch; private readonly config; private queue; private flushTimer; private errorFingerprints; private cleanupTimer; private readonly logger; constructor(config: ErrorQueueConfig | undefined, sendBatch: (errors: ErrorReportPayload[]) => Promise<void>, debug?: boolean); /** * Add error to queue */ add(error: ErrorReportPayload): Promise<void>; /** * Flush queue immediately */ flush(): Promise<void>; /** * Destroy queue and cleanup resources */ destroy(): void; /** * Get current queue size */ size(): number; /** * Check if error is duplicate */ private isDuplicate; /** * Update error fingerprint */ private updateFingerprint; /** * Get error fingerprint (hash key) */ private getFingerprint; /** * Schedule flush */ private scheduleFlush; /** * Cancel scheduled flush */ private cancelScheduledFlush; /** * Start cleanup timer for old fingerprints */ private startCleanupTimer; /** * Stop cleanup timer */ private stopCleanupTimer; /** * Clean up old fingerprints to prevent memory leak */ private cleanupOldFingerprints; } //# sourceMappingURL=ErrorQueue.d.ts.map