feat(socket): integrate circuit breaker with Socket operations

- Add circuit breaker configuration options to SocketConfig type
- Initialize circuit breakers for query, connection, and pre-key operations
- Wrap query() with circuit breaker protection for all WhatsApp queries
- Wrap sendRawMessage() with connection circuit breaker
- Integrate pre-key circuit breaker with uploadPreKeys()
- Add circuit breaker utilities to socket return object (stats, reset)
- Clean up circuit breakers on connection close
- Fix TypeScript errors in utility files (prometheus-metrics, logger-adapter, etc.)

Circuit breakers provide:
- Sliding window failure tracking
- Automatic state transitions (closed -> open -> half-open)
- Configurable thresholds and timeouts
- Prometheus metrics integration
- Event callbacks for monitoring
This commit is contained in:
Claude
2026-01-20 02:31:23 +00:00
parent 64c7712da7
commit 61f5f76ef0
9 changed files with 212 additions and 22 deletions
+3 -1
View File
@@ -77,7 +77,9 @@ export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
countryCode: 'US',
getMessage: async () => undefined,
cachedGroupMetadata: async () => undefined,
makeSignalRepository: makeLibSignalRepository
makeSignalRepository: makeLibSignalRepository,
// Circuit breaker configuration
enableCircuitBreaker: true
}
export const MEDIA_PATH_MAP: { [T in MediaType]?: string } = {