All Projects → dmexe → Failsafe Rs

dmexe / Failsafe Rs

A circuit breaker implementation for rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Failsafe Rs

Ganesha
🐘 A Circuit Breaker pattern implementation for PHP applications.
Stars: ✭ 384 (+225.42%)
Mutual labels:  circuit-breaker
Sample Camel Spring Boot
three samples in different branches that illustrates usage of apache camel as microservice framework providing integration with consul, hystrix, ribbon and other tools
Stars: ✭ 24 (-79.66%)
Mutual labels:  circuit-breaker
Rezilience
ZIO-native utilities for making resilient distributed systems
Stars: ✭ 60 (-49.15%)
Mutual labels:  circuit-breaker
Opossum
Node.js circuit breaker - fails fast ⚡️
Stars: ✭ 473 (+300.85%)
Mutual labels:  circuit-breaker
Guard
NOT MAINTAINED! A generic high performance circuit breaker & proxy server written in Go
Stars: ✭ 745 (+531.36%)
Mutual labels:  circuit-breaker
Semian
🐒 Resiliency toolkit for Ruby for failing fast
Stars: ✭ 976 (+727.12%)
Mutual labels:  circuit-breaker
Sentinel
A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
Stars: ✭ 18,071 (+15214.41%)
Mutual labels:  circuit-breaker
Circuit B
A non intrusive circuit breaker for node.js
Stars: ✭ 88 (-25.42%)
Mutual labels:  circuit-breaker
Luffy
Luffy is a simple resilience and transient-fault handling library
Stars: ✭ 19 (-83.9%)
Mutual labels:  circuit-breaker
Circuit Breaker Monad
Circuit Breaker pattern as a monad
Stars: ✭ 52 (-55.93%)
Mutual labels:  circuit-breaker
Samples
Steeltoe samples and reference application collection
Stars: ✭ 586 (+396.61%)
Mutual labels:  circuit-breaker
Istio
Connect, secure, control, and observe services.
Stars: ✭ 28,970 (+24450.85%)
Mutual labels:  circuit-breaker
Cockatiel
A resilience and transient-fault-handling library that allows developers to express policies such as Backoff, Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback. Inspired by .NET Polly.
Stars: ✭ 993 (+741.53%)
Mutual labels:  circuit-breaker
Service Pattern Go
Simple clean Go REST API architecture with dependency injection and mocking example, following SOLID principles.
Stars: ✭ 449 (+280.51%)
Mutual labels:  circuit-breaker
Failurewall
Destroys failures.
Stars: ✭ 64 (-45.76%)
Mutual labels:  circuit-breaker
Spring Cloud Alibaba
Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
Stars: ✭ 20,934 (+17640.68%)
Mutual labels:  circuit-breaker
Breaker
Circuit breaker for HTTP requests in Elixir
Stars: ✭ 30 (-74.58%)
Mutual labels:  circuit-breaker
Gobreaker
Circuit Breaker implemented in Go
Stars: ✭ 1,867 (+1482.2%)
Mutual labels:  circuit-breaker
Polly
Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. From version 6.0.1, Polly targets .NET Standard 1.1 and 2.0+.
Stars: ✭ 9,944 (+8327.12%)
Mutual labels:  circuit-breaker
Recloser
A concurrent circuit breaker implemented with ring buffers
Stars: ✭ 51 (-56.78%)
Mutual labels:  circuit-breaker

Failsafe

Сrate Вocumentation CircleCI Appveyor

A circuit breaker implementation which used to detect failures and encapsulates the logic of preventing a failure from constantly recurring, during maintenance, temporary external system failure or unexpected system difficulties.

Features

  • Working with both Fn() -> Result and Future (optional via default futures-support feature).
  • Backoff strategies: constant, exponential, equal_jittered, full_jittered
  • Failure detection policies: consecutive_failures, success_rate_over_time_window
  • Minimum rust version: 1.39

Usage

Add this to your Cargo.toml:

failsafe = "1.0.0"

Example

Using default backoff strategy and failure accrual policy.

use failsafe::{Config, CircuitBreaker, Error};

// A function that sometimes failed.
fn dangerous_call() -> Result<(), ()> {
  if thread_rng().gen_range(0, 2) == 0 {
    return Err(())
  }
  Ok(())
}

// Create a circuit breaker which configured by reasonable default backoff and
// failure accrual policy.
let circuit_breaker = Config::new().build();

// Call the function in a loop, after some iterations the circuit breaker will
// be in a open state and reject next calls.
for n in 0..100 {
  match circuit_breaker.call(|| dangerous_call()) {
    Err(Error::Inner(_)) => {
      eprintln!("{}: fail", n);
    },
    Err(Error::Rejected) => {
       eprintln!("{}: rejected", n);
       break;
    },
    _ => {}
  }
}

Or configure custom backoff and policy:

use std::time::Duration;
use failsafe::{backoff, failure_policy, CircuitBreaker};

// Create an exponential growth backoff which starts from 10s and ends with 60s.
let backoff = backoff::exponential(Duration::from_secs(10), Duration::from_secs(60));

// Create a policy which failed when three consecutive failures were made.
let policy = failure_policy::consecutive_failures(3, backoff);

// Creates a circuit breaker with given policy.
let circuit_breaker = Config::new()
  .failure_policy(policy)
  .build();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].