Add circuit breaker for Hiya/Truecaller external APIs (FRE-4508)
- Implement CircuitBreaker class with CLOSED/OPEN/HALF_OPEN states - Configurable failure threshold, success threshold, and timeout - Fallback behavior when circuit opens (returns neutral 0.5 score) - State change callbacks for monitoring and logging - Comprehensive metrics tracking (executions, failures, successes, timestamps) - Update SpamShieldService to use circuit breakers for both Hiya and Truecaller - Add parallel API calls with graceful degradation - Export circuit breaker types and service interfaces - 32 unit tests covering circuit transitions, fallback, and service integration Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
5
services/spamshield/src/index.ts
Normal file
5
services/spamshield/src/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export { SpamShieldService } from './services/spamshield.service';
|
||||
export type { ReputationResult, CircuitMetrics } from './services/spamshield.service';
|
||||
export { spamRateLimits, spamFeatureFlags, spamConfig } from './config/spamshield.config';
|
||||
export { CircuitBreaker, CircuitBreakerError } from './circuit-breaker';
|
||||
export type { CircuitState, CircuitBreakerMetrics, CircuitBreakerOptions } from './circuit-breaker';
|
||||
Reference in New Issue
Block a user