# `Rexsilient.CircuitBreaker.Strategy.SlidingWindow`
[🔗](https://github.com/fabiobarkoski/rexsilient/blob/v1.0.0/lib/rexsilient/circuit_breaker/strategy/sliding_window.ex#L1)

Opens the breaker after a number of failures within a time window.

Only failures are tracked: the breaker opens when `threshold` failures
happen within `window` milliseconds of each other. Successes do not affect
it, and failures older than the window stop counting.

## Options

  * `:threshold` - the number of failures that opens the breaker. Required.

    With `1`, the first failure opens the breaker and `:window` has no
    effect, like `Rexsilient.CircuitBreaker.Strategy.Count` with the same
    threshold.

    The breaker keeps the time of the last `threshold - 1` failures, 8 bytes
    each, so memory grows with the threshold.

  * `:window` - the time, in milliseconds, those failures must fit in.
    Required.

## Examples

    strategy Rexsilient.CircuitBreaker.Strategy.SlidingWindow,
      threshold: 5,
      window: :timer.seconds(10)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
