Skip to content

Commit

Permalink
Add ADR draft
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Apr 16, 2024
1 parent d5acdb7 commit e2be112
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions apps/website/docs/adr/barrier_circuit_breaker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Barrier Circuit Breaker

outline: [2, 3]

version: v0.13
---

# Barrier Circuit Breaker

This ADR is effective starting from [v0.13](/releases/0-13).

::: tip TL;DR

Added optional `circuitBreaker` to [`createBarrier`](/api/factories/create_barrier) to allow adding custom circuit breaker logic to a [_Barrier_](/api/primitives/barrier).

```ts
const authBarrier = createBarrier({
activateOn: {
failure: isHttpErrorCode(401),
},
perform: [getTokenMutation],
circuitBreaker({ performed, deactivated, $active, breakCircuit }) {
const $times = createStore(0);

sample({
clock: performed,
filter: $active,
source: $times,
fn: (times) => times + 1,
target: $times,
});

sample({
clock: $times,
filter: (times) => times > 10,
target: breakCircuit,
});

sample({
clock: deactivated,
target: $times.reinit,
});
},
});
```

:::

## Problem

::: tip
Original issue: [farfetched#458](https://github.com/igorkamyshev/farfetched/issues/458)
:::

0 comments on commit e2be112

Please sign in to comment.