documentation/dsls/DSL-AshCircuitBreaker.md
<!--
This file was generated by Spark. Do not edit it by hand.
-->
# 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](https://hex.pm/packages/fuse) package to provide
circuit breaker features. See [fuse's documentation](https://hexdocs.pm/fuse) 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
* [action](#circuit-action)
### circuit.action
```elixir
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
| Name | Type | Default | Docs |
|------|------|---------|------|
| [`action`](#circuit-action-action){: #circuit-action-action .spark-required} | `atom` | | The name of the action to wrap in a circuit breaker |
### Options
| Name | Type | Default | Docs |
|------|------|---------|------|
| [`limit`](#circuit-action-limit){: #circuit-action-limit .spark-required} | `pos_integer` | | The maximum number of failures allowed before the circuit opens |
| [`per`](#circuit-action-per){: #circuit-action-per .spark-required} | `pos_integer` | | The time period (in milliseconds) for which failures are counted |
| [`reset_after`](#circuit-action-reset_after){: #circuit-action-reset_after .spark-required} | `pos_integer` | | The time period (in milliseconds) after which the circuit will attempt to close again |
| [`name`](#circuit-action-name){: #circuit-action-name } | `atom \| (any -> any) \| (any, any -> any)` | `&AshCircuitBreaker.name_for_breaker/1` | The 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?`](#circuit-action-should_break?){: #circuit-action-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`
<style type="text/css">.spark-required::after { content: "*"; color: red !important; }</style>