AshCircuitBreaker

An extension for Ash.Resource which adds the ability to wrap actions in circuit breakers to allow for graceful handling of and recovery from failures.

circuit

Configure a circuit breaker for actions.

Note that this extension does not support circuit breaking for read/query actions.

Fuse

This library uses the fuse package to provide circuit breaker features. See fuse's documentation for more information.

Names

Fuse uses an atom "name" value as a reference to a specific circuit breaker. By default, the name is derived from the action name and resource name. You can provide a custom name using the name option.

Nested DSLs

circuit.action

action action

Configure a circuit breaker for a single action.

It does this by adding a global change or preparation to the resource with the provided configuration.

Arguments

NameTypeDefaultDocs
actionatomThe name of the action to wrap in a circuit breaker

Options

NameTypeDefaultDocs
limitpos_integerThe maximum number of failures allowed before the circuit opens
perpos_integerThe time period (in milliseconds) for which failures are counted
reset_afterpos_integerThe time period (in milliseconds) after which the circuit will attempt to close again
nameatom | (any -> any) | (any, any -> any)&AshCircuitBreaker.name_for_breaker/1The name to use for the circuit breaker. This can be an atom or a function that takes a query/changeset and optional context object to generate an atom key.
should_break?nil | (any -> any)A function that takes the error and returns true if the circuit should break. If not provided, the circuit will break on any error.

Introspection

Target: AshCircuitBreaker