CircuitBreakerExtension
Defined in: src/pattern/CircuitBreakerExtension.ts:66
System-wide registry for named circuit breakers.
new CircuitBreaker({...}) is unchanged and remains the door for a breaker
whose settings live in code. What this adds is the other door: a breaker
resolved by id, whose numbers an operator can change in
application.conf without a deploy, and whose state outlives the actor
that uses it — which is what the “don’t share a breaker across an actor
restart” advice on the pattern page has been asking for.
const breaker = system.extension(CircuitBreakerExtensionId).breaker('payment-api');Each id is a separate instance with separate settings, layered in the
project’s precedence order: actor-ts.circuit-breaker.<id>.* over
actor-ts.circuit-breaker.default.* over the built-in floor, leaf by leaf,
with explicit options above all three. Two consumers that trip
independently is the whole of the one-breaker-per-dependency advice, applied
to a place where it can be configured rather than only recommended.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CircuitBreakerExtension(
system):CircuitBreakerExtension
Defined in: src/pattern/CircuitBreakerExtension.ts:69
Parameters
Section titled “Parameters”system
Section titled “system”Returns
Section titled “Returns”CircuitBreakerExtension
Methods
Section titled “Methods”breaker()
Section titled “breaker()”breaker(
id?,explicitOptions?):CircuitBreaker
Defined in: src/pattern/CircuitBreakerExtension.ts:92
The breaker configured as id, created on first use and cached after.
explicitOptions sits above both config layers and is read once, when
the instance is created — a second breaker(id) with different options
returns the instance that already exists rather than reconfiguring it,
the same contract CacheExtension.cache(name) has. Options a config file
cannot express (isFailure, random) are what it is for.
Which makes it the wrong door for a shared or published id. Whoever
resolves the id first decides, and every later caller’s options are
dropped in silence — so an isFailure handed over here reaches the
breaker only by luck of ordering, and a classifier that belongs to the
protected dependency should be passed to CircuitBreaker.call instead,
where it travels with the call (#874). The framework’s own persistence
breakers do exactly that and pass no options here at all.
Values from either block are validated when the breaker is constructed, so
a typo’d override throws OptionsError at the first breaker(id) rather
than leaving that one instance quietly running the framework defaults.
Parameters
Section titled “Parameters”string = DEFAULT_CIRCUIT_BREAKER_ID
explicitOptions?
Section titled “explicitOptions?”Returns
Section titled “Returns”names()
Section titled “names()”names():
string[]
Defined in: src/pattern/CircuitBreakerExtension.ts:106
The ids resolved so far — diagnostic only.
Returns
Section titled “Returns”string[]
setBreaker()
Section titled “setBreaker()”setBreaker(
id,breaker):void
Defined in: src/pattern/CircuitBreakerExtension.ts:101
Replace the breaker instance for id directly — useful for tests.
Parameters
Section titled “Parameters”string
breaker
Section titled “breaker”Returns
Section titled “Returns”void
