Skip to content

Latest commit

 

History

History
13 lines (7 loc) · 694 Bytes

README.md

File metadata and controls

13 lines (7 loc) · 694 Bytes

circuit-breaker-ts

Dependency free circuit breaker.

Given a thunk () => Promise<A>, allow a configurable number of errors to occur before any subsequent calls to the thunk are short-circuited for a set amount of time.

The error threshold, error message and back off time are configurable.

Useful for protecting calls to external services that may experience an outage.

A convenience function that returns a singleton is available so that an instance can be built at app startup and injected into services.

Inspired by a great blog post on circuit breakers in the functional world