All Projects → hootsuite → scala-circuit-breaker

hootsuite / scala-circuit-breaker

Licence: other
A circuit breaker for Scala applications and services

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to scala-circuit-breaker

Circuitbreaker
.NET Circuit Breaker Pattern Frameworks
Stars: ✭ 122 (+258.82%)
Mutual labels:  circuit-breaker
Uragano
Uragano, A simple, high performance RPC library. Support load balancing, circuit breaker, fallback, caching, intercepting.
Stars: ✭ 28 (-17.65%)
Mutual labels:  circuit-breaker
spring-microservices
Spring Cloud Micro Services with Eureka Discovery, Zuul Proxy, OAuth2 Security, Hystrix CircuitBreaker, Sleuth Zipkin, ELK Stack Logging, Kafka, Docker and many new features
Stars: ✭ 114 (+235.29%)
Mutual labels:  circuit-breaker
Safely
Safely is a Clojure's circuit-breaker library for handling retries in an elegant declarative way.
Stars: ✭ 152 (+347.06%)
Mutual labels:  circuit-breaker
Diehard
Clojure library of flexible retry, circuit breaker and rate limiter
Stars: ✭ 227 (+567.65%)
Mutual labels:  circuit-breaker
circuit-breaker
PHP implementation of circuit breaker pattern
Stars: ✭ 17 (-50%)
Mutual labels:  circuit-breaker
Gobreaker
Circuit Breaker implemented in Go
Stars: ✭ 1,867 (+5391.18%)
Mutual labels:  circuit-breaker
Sentinel-Dashboard-Nacos
Description Sentinel Dashboard使用NACOS作为数据源持久化规则。【仅用于教学,如用于生产,请务必做好测试!】
Stars: ✭ 87 (+155.88%)
Mutual labels:  circuit-breaker
resiliency
A modern PHP library that allows you to make resilient calls to external services 🔁
Stars: ✭ 79 (+132.35%)
Mutual labels:  circuit-breaker
request-on-steroids
An HTTP client ✨ with retry, circuit-breaker and tor support 📦 out-of-the-box
Stars: ✭ 19 (-44.12%)
Mutual labels:  circuit-breaker
Tree Gateway
This is a full featured and free API Gateway
Stars: ✭ 160 (+370.59%)
Mutual labels:  circuit-breaker
Circuit Breaker Php
Circuit Breaker Pattern for PHP
Stars: ✭ 202 (+494.12%)
Mutual labels:  circuit-breaker
yato
A node module similar to hystrix. Who caused riots - cut it!
Stars: ✭ 12 (-64.71%)
Mutual labels:  circuit-breaker
Heimdall
An enhanced HTTP client for Go
Stars: ✭ 2,132 (+6170.59%)
Mutual labels:  circuit-breaker
Connectors
Connectors simplify connecting to standalone and CloudFoundry services
Stars: ✭ 28 (-17.65%)
Mutual labels:  circuit-breaker
Failsafe Rs
A circuit breaker implementation for rust
Stars: ✭ 118 (+247.06%)
Mutual labels:  circuit-breaker
lua-circuit-breaker
Circuit breaker pattern in Lua
Stars: ✭ 28 (-17.65%)
Mutual labels:  circuit-breaker
envoy-proxy-demos
Set of Envoy Proxy feature demos (Envoy v2 API supported)
Stars: ✭ 63 (+85.29%)
Mutual labels:  circuit-breaker
microservices-developer-roadmap
Roadmap for becoming a Microservice Developer in 2017
Stars: ✭ 24 (-29.41%)
Mutual labels:  circuit-breaker
CircuitBreaker
A Swift Circuit Breaker library – Improves application stability and reliability.
Stars: ✭ 42 (+23.53%)
Mutual labels:  circuit-breaker

Circuit Breaker

What is a Circuit Breaker?

A circuit breaker monitors the number of failed requests and decides to delay sending further requests based on configurable threshold. Read more about circuit breakers. Failure threshold, delay time, failure criteria, and event listeners are configurable in config file and code.

Our solution has been powering Scala services in production. It's battle tested and proven.

Quick start guide

Installation

build.sbt

resolvers += Resolver.jcenterRepo // Adds Bintray to resolvers
libraryDependencies ++= Seq("com.hootsuite" %% "scala-circuit-breaker" % "1.x.x")

Usage

Use CircuitBreakerBuilder to initialize circuit breaker:

Configure circuit breaker in reference.conf

circuit-breaker {
  fail-limit = 5 # maximum number of consecutive failures before the circuit breaker is tripped (opened)
  retry-delay = 10 seconds # duration until an open/broken circuit breaker lets a call through to verify whether or not it should be reset
}

Optionally, define the following:

  • a partial function that determines what should be considered as failures

  • a partial function that determines what exceptions that should NOT be considered as failures

  • listeners that will be notified when the circuit breaker changes state (open <--> closed)

  • listeners that will be notified whenever the circuit breaker handles a method/function call

Example

def circuitBreakerBuilder(name: String): CircuitBreakerBuilder = {
    new CircuitBreakerBuilder(
      name = name,
      failLimit = config.getInt("circuit-breaker.fail-limit"),
      retryDelay = Duration(config.getDuration("circuit-breaker.retry-delay", TimeUnit.SECONDS), TimeUnit.SECONDS))
      .withNonFailureExceptionCases {
        // Ignore 4xx level responses
        case _: BadRequest => true
        case _: Unauthorized => true
        case _: NotFound => true
      }
      .withStateChangeListeners(stateChangeListeners)
      .withInvocationListeners(invocationListeners)
  }

Demo

See scala-circuit-breaker-example

How to contribute

Contribute by submitting a PR and a bug report in GitHub.

Maintainers

Diego Alvarez @d1egoaz

Andres Rama @andres_rama_hs

Steve Song @ssongvan

Tatsuhiro Ujihisa @ujm

Johnny Bufu

scala-circuit-breaker is Open Source and available under the Apache 2 License.

This project took inspiration from Sentries which has a BSD 2-Clause License, our solution includes ability to fine-tune what should be considered as failures. It also has hooks when circuit breaker states change.

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].