refactor(utils): remove circuit-breaker integration from helpers
- Utils/index.ts: re-export bounded-retry instead of circuit-breaker - Utils/unified-session.ts: drop the optional circuit-breaker wrapping. Telemetry is non-critical; a single send attempt with the underlying sendNode timeout is sufficient. Removed enableCircuitBreaker option, circuitBreaker field, and CircuitOpenError handling. - Utils/retry-utils.ts: drop the optional circuitBreaker option from withRetry. Retry mechanics are now self-contained; callers that need bounded retries should prefer withBoundedRetry directly. - Utils/health-status.ts: stop importing globalCircuitRegistry. Keep the CircuitBreakerHealth shape for k8s probe schema stability — always reports an empty list now. Note: src/Utils/structured-logger.ts has its own *private* CircuitBreaker class for log-throttling — independent of the socket-level circuit breaker being removed. Untouched. baileys-logger.ts logCircuitBreaker() is a generic logging helper that takes state strings as input — no import dependency. Untouched (no-op for callers that no longer have circuit breakers).
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import type { CircuitBreaker } from './circuit-breaker.js'
|
||||
import { metrics } from './prometheus-metrics.js'
|
||||
|
||||
/**
|
||||
@@ -59,8 +58,6 @@ export interface RetryOptions {
|
||||
operationName?: string
|
||||
/** Collect metrics */
|
||||
collectMetrics?: boolean
|
||||
/** Circuit breaker for integration */
|
||||
circuitBreaker?: CircuitBreaker
|
||||
/** Callback before each retry */
|
||||
onRetry?: (error: Error, attempt: number, delay: number) => void | Promise<void>
|
||||
/** Callback on success */
|
||||
@@ -283,7 +280,6 @@ export async function retry<T>(
|
||||
timeout: options.timeout,
|
||||
operationName: options.operationName ?? 'operation',
|
||||
collectMetrics: options.collectMetrics ?? true,
|
||||
circuitBreaker: options.circuitBreaker,
|
||||
onRetry: options.onRetry ?? (() => {}),
|
||||
onSuccess: options.onSuccess ?? (() => {}),
|
||||
onFailure: options.onFailure ?? (() => {}),
|
||||
@@ -313,11 +309,6 @@ export async function retry<T>(
|
||||
throw new RetryAbortedError(attempt)
|
||||
}
|
||||
|
||||
// Check circuit breaker
|
||||
if (config.circuitBreaker?.isOpen()) {
|
||||
throw new Error(`Circuit breaker "${config.circuitBreaker.getName()}" is open`)
|
||||
}
|
||||
|
||||
try {
|
||||
// Execute operation
|
||||
let result: T
|
||||
|
||||
Reference in New Issue
Block a user