콘텐츠로 이동
한국어

CircuitBreaker

이 콘텐츠는 아직 번역되지 않았습니다.

Defined in: src/pattern/CircuitBreaker.ts:31

Three-state circuit breaker. Wraps calls that might fail — when enough fail in a row the breaker “opens” and refuses further calls for a timeout window. The first call after the timeout probes the upstream (“half-open”); if it succeeds, the breaker closes and normal operation resumes.

Not tied to actors — works with any () => Promise<T> factory. For actor-based usage, wrap ask(target, msg, timeout) in the factory.

new CircuitBreaker(options): CircuitBreaker

Defined in: src/pattern/CircuitBreaker.ts:39

CircuitBreakerOptions

CircuitBreaker

readonly options: CircuitBreakerOptionsType

Defined in: src/pattern/CircuitBreaker.ts:37

get state(): CircuitState

Defined in: src/pattern/CircuitBreaker.ts:45

CircuitState

call<T>(factory): Promise<T>

Defined in: src/pattern/CircuitBreaker.ts:48

Call factory under breaker supervision. Throws CircuitBreakerOpenError when open.

T

() => Promise<T>

Promise<T>


onStateChange(listener): () => void

Defined in: src/pattern/CircuitBreaker.ts:69

Observe state transitions — useful for logging/metrics.

StateListener

() => void


setState(next): void

Defined in: src/pattern/CircuitBreaker.ts:75

Force the breaker into a specific state (mostly for tests / admin).

CircuitState

void