import { OnModuleDestroy, CanActivate, ExecutionContext, NestInterceptor, CallHandler } from '@nestjs/common'; import { CircuitBreakerRegistry, CircuitBreakerMetrics } from '../index.cjs'; import * as _nestjs_core from '@nestjs/core'; import { Reflector } from '@nestjs/core'; import { Observable } from 'rxjs'; declare class CircuitBreakerModule { } declare class CircuitBreakerService implements OnModuleDestroy { private readonly registry; private readonly logger; private monitorInterval; constructor(registry: CircuitBreakerRegistry); onModuleDestroy(): void; getAllMetrics(): Record; getOpenBreakers(): CircuitBreakerMetrics[]; reset(name: string): void; resetAll(): void; private startMonitoring; } interface CircuitBreakerGuardOptions { /** Named circuit breaker to use */ name: string; /** Failure threshold % to open the circuit. Default: 50 */ failureThreshold?: number; /** * Custom error classifier. Defaults to `isHttpServerError`: * only HTTP 5xx and non-HTTP errors open the circuit. */ isFailure?: (error: unknown) => boolean; } declare const UseCircuitBreaker: (options: CircuitBreakerGuardOptions) => _nestjs_core.ReflectableDecorator; declare class CircuitBreakerGuard implements CanActivate { private readonly reflector; private readonly registry; constructor(reflector: Reflector, registry: CircuitBreakerRegistry); canActivate(context: ExecutionContext): boolean; } declare class CircuitBreakerInterceptor implements NestInterceptor { private readonly registry; constructor(registry: CircuitBreakerRegistry); intercept(context: ExecutionContext, next: CallHandler): Promise>; } /** * Method decorator that wraps execution inside a named circuit breaker. * The class must have `circuitBreakerRegistry: CircuitBreakerRegistry` injected. * * Business errors (HTTP 4xx by default) pass through without affecting the circuit state. * * @throws Error at decoration time if the registry is not injected in the class. */ declare function WithCircuitBreaker(options: { name: string; failureThreshold?: number; openTimeoutMs?: number; isFailure?: (error: unknown) => boolean; fallback?: (error: unknown) => unknown | Promise; }): (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; export { CircuitBreakerGuard, type CircuitBreakerGuardOptions, CircuitBreakerInterceptor, CircuitBreakerModule, CircuitBreakerService, UseCircuitBreaker, WithCircuitBreaker };