All Projects → failurewall → Failurewall

failurewall / Failurewall

Licence: apache-2.0
Destroys failures.

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Failurewall

Constructr Consul
This library enables to use Consul as cluster coordinator in a ConstructR based node
Stars: ✭ 32 (-50%)
Mutual labels:  akka
Psf Loginserver
Emulated PlanetSide 1 world and login server by the PSForever project.
Stars: ✭ 46 (-28.12%)
Mutual labels:  akka
Circuit Breaker Monad
Circuit Breaker pattern as a monad
Stars: ✭ 52 (-18.75%)
Mutual labels:  circuit-breaker
Toketi Iothubreact
Akka Stream library for Azure IoT Hub
Stars: ✭ 36 (-43.75%)
Mutual labels:  akka
Akka Wamp
WAMP - Web Application Messaging Protocol implementation written with Akka
Stars: ✭ 45 (-29.69%)
Mutual labels:  akka
Nsdb
Natural Series Database
Stars: ✭ 49 (-23.44%)
Mutual labels:  akka
Akkeeper
An easy way to deploy your Akka services to a distributed environment.
Stars: ✭ 30 (-53.12%)
Mutual labels:  akka
Rezilience
ZIO-native utilities for making resilient distributed systems
Stars: ✭ 60 (-6.25%)
Mutual labels:  circuit-breaker
Spark As Service Using Embedded Server
This application comes as Spark2.1-as-Service-Provider using an embedded, Reactive-Streams-based, fully asynchronous HTTP server
Stars: ✭ 46 (-28.12%)
Mutual labels:  akka
Play Spark Scala
Stars: ✭ 51 (-20.31%)
Mutual labels:  akka
Heimdallr
Heimdallr, a Large-scale chat application server based on Redis Pubsub and Akka's actor model.
Stars: ✭ 38 (-40.62%)
Mutual labels:  akka
Akka Trading
Scala Backtesting + Oanda REST API Trading Framework built on top of Akka/Spray
Stars: ✭ 40 (-37.5%)
Mutual labels:  akka
Jersey2 Akka Java
An example async Java REST API using Jersey 2 and Akka
Stars: ✭ 50 (-21.87%)
Mutual labels:  akka
Semian
🐒 Resiliency toolkit for Ruby for failing fast
Stars: ✭ 976 (+1425%)
Mutual labels:  circuit-breaker
Utils4s
scala、spark使用过程中,各种测试用例以及相关资料整理
Stars: ✭ 1,070 (+1571.88%)
Mutual labels:  akka
Breaker
Circuit breaker for HTTP requests in Elixir
Stars: ✭ 30 (-53.12%)
Mutual labels:  circuit-breaker
Akka Typed Session
add-on to Akka Typed that tracks effects for use with Session Types
Stars: ✭ 47 (-26.56%)
Mutual labels:  akka
Akka Tools
Open source tools to simplify Akka event sourcing, journaling/persistence, serialization, clustering and sharding.
Stars: ✭ 60 (-6.25%)
Mutual labels:  akka
Protoactor Dotnet
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
Stars: ✭ 1,070 (+1571.88%)
Mutual labels:  akka
Recloser
A concurrent circuit breaker implemented with ring buffers
Stars: ✭ 51 (-20.31%)
Mutual labels:  circuit-breaker

Failurewall

Build Status

This is a library to protect applications against failures, and helpful in developing stable, responsive and resilient systems.

Failurewall is inspired by Hystrix and adapted for scala.concurrent.Future.

Getting Started

You should add the following dependency.

libraryDependencies += "com.okumin" %% "failurewall-core" % "0.2.0"

If you are using Akka 2.4, you can use failurewall-akka. failurewall-akka provides the following failurewalls.

  • circuit breaker
  • retry with backoff
  • timeout
libraryDependencies += "com.okumin" %% "failurewall-akka" % "0.2.0"

If you are using Akka 2.3, see also failurewall-akka23.

How to use

As a Proxy

Failurewall is simple to use, wrapping scala.concurrent.Future to be protected. Each failurewall has abilities to handle failures.

object HttpClient {
  def get(url: String): Future[Response] = ???
}

val wall: Failurewall[Response, Response] = ???
val response: Future[Response] = wall.call(HttpClient.get("http://okumin.com/"))

Composability

Failurewalls has their own ability, e.g. retrying, checking rate limits and throttling. Failurewall#compose makes Failurewalls decorate such features.

val wallSina: Failurewall[Int, String] = ???
val wallRose: Failurewall[Int, Int] = ???
val wallMaria: Failurewall[Double, Int] = ???

val walls: [Double, String] = wallSina compose wallRose compose wallMaria

Built-in walls(failurewall-core)

RetryFailurewall

Retries on temporary failures.

val wall = RetryFailurewall[Response](10, executionContext)
wall.call(Future.failed(new RuntimeException)) // retry 10 times

StdSemaphoreFailurewall

Keeps resource usage constant.

val wall = StdSemaphoreFailurewall[Response](10, executionContext)
val results = (1 to 100).map { _ =>
  // fails immediately while other 10 calls are running
  wall.call(doSomeOperation())
}

StopwatchFailurewall

Measures the execution time.

val wall = StopwatchFailurewall[Response](executionContext)
wall.call(doSomeOperation()) // returns Future[(Try[Response], FiniteDuration)]

Built-in walls(failurewall-akka)

AkkaCircuitBreakerFailurewall

Prevents a failure from leading to cascading other failures.

// has a little complicated constructor
val wall: AkkaCircuitBreakerFailurewall[Response] = ???
val results = (1 to 100).map { _ =>
  // fail-fast after failure times exceeds the threshold
  wall.call(Future {
    throw new RuntimeException
  })
}

AkkaRetryFailurewall

Retries with backoff on temporary failures.

val backoffStrategy = ExponentialBackoffStrategy(
  minBackoff = 100.millis,
  maxBackoff = 10.seconds,
  multiplier = 2.0
)
val wall = AkkaRetryFailurewall[Response](
  10,
  backoffStrategy,
  akkaScheduler,
  executionContext
)
// retry 10 times with exponential backoff
wall.call(Future.failed(new RuntimeException))

AkkaTimeoutFailurewall

Times out when it takes some duration.

val wall = AkkaTimeoutFailurewall[String](5.seconds, akkaScheduler, executionContext) {
  logger.error("Timed out.")
}
// fails with FailurewallException
wall.call(Future {
  Thread.sleep(10000)
  "mofu"
})
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].