circuit-breaker alternatives and similar packages
Based on the "System" category.
Alternatively, view circuit-breaker alternatives based on common mentions on social networks and blogs.
-
taffybar
A gtk based status bar for tiling window managers such as XMonad -
nix-deploy
Deploy software or an entire NixOS system configuration to another NixOS system -
ghc-hotswap
Example code for how we swap compiled code within a running Haskell process. -
optparse-generic
Auto-generate a command-line parser for your datatype -
hapistrano
Deploy tool for Haskell applications, like Capistrano for Rails -
directory
Platform-independent library for basic file system operations -
typed-process
Alternative API for processes, featuring more type safety -
pid1
Do signal handling and orphan reaping for Unix PID1 init processes -
hnix-store-core
Haskell implementation of the nix store API -
clock
High-resolution clock functions: monotonic, realtime, cputime. -
system-fileio
Contains the system-filepath and system-fileio packages -
language-puppet
A library to work with Puppet manifests, test them and eventually replace everything ruby. -
openssh-github-keys
Control SSH access to your servers via GitHub teams -
plugins
Dynamic linking and runtime evaluation of Haskell, and C, including dependency chasing and package resolution. -
ascii-progress
A simple Haskell progress bar for the console. Heavily borrows from TJ Holowaychuk's Node.JS project -
optparse-declarative
Declarative command-line option parser -
directory-contents
Recursively build a tree of directory contents, avoiding symlink cycles -
halfs
The Haskell File System: A file system implementation in Haskell -
executable-hash
Provides the SHA1 hash of the program executable
Clean code begins in your IDE with SonarLint
Do you think we are missing an alternative of circuit-breaker or a related project?
README
circuit-breaker
Circuit breakers are an error handling machine inspired by the circuit breakers used in electrical systems. Just like their namesake, software circuit breakers prevent pushing traffic through a failing component until it has recovered.
As of the current version, all CircuitBreaker
s use a "leaky bucket" approach to backoffs.
In the definition of a circuit breaker, the first Natural
argument is the number of milliseconds that need to pass before an error is expunged.
Coupled with an error threshold argument, this provides a surprising amount of flexibility for cirucit breakers in the wild, although you'll want to monitor and tune them over time.
Using a circuit breaker
The following short example illustrates how to define a circuit breaker & use it.
testBreaker :: CircuitBreaker "Test" 1000 4
testBreaker = undefined
main :: IO ()
main = do
-- Initializes the empty storage for all circuit breakers
cbConf <- initialBreakerState
-- Perform a bunch of "work". Because we have a 50% failure rate and trigger the breaker after four
-- errors, this will cause the breaker to disable additional calls.
forM_ [1..30] $ const . noteError . flip runReaderT cbConf $ withBreaker testBreaker computation
-- simulating a backoff long enough to decrement the accumulated errors.
threadDelay 5000000
noteError . flip runReaderT cbConf $ withBreaker testBreaker computation
where
noteError action = print =<< catchAny action (const $ pure (Left Failed))
-- | This computation fails 50% of the time
computation :: ReaderT CircuitBreakerConf IO Int
computation = do
shouldFail <- liftIO randomIO
when shouldFail $ error "Failed"
pure 42
The first thing to notice is that the CircuitBreaker
definition exists entirely at the type level.
This guarantees that the definition of a particular CircuitBreaker
can't somehow change at runtime.
All calls to withBreaker
require a CircuitBreakerConf
to be present in a reader environment.
initialBreakerState
simply initializes an empty CircuitBreakerConf
to save you the trouble of creating one yourself.
Contributing
PRs and issues are welcome! Please let me know what you think could be improved or submit the patch yourself.
License
MIT
*Note that all licence references and agreements mentioned in the circuit-breaker README section above
are relevant to that project's source code only.