Rexsilient - A resilience toolkit for Elixir

Hello everybody,

I want to share a library that I’ve been working on, Rexsilient. It’s inspired by Polly and Hystrix, and the goal is the same: to provide resilient patterns to be used on Elixir projects. It already includes circuit breaker, retry, and fallback patterns, but the goal is to add more.

The idea is to be very easy to use: create a module declaring what you want to use and then use decorator to call, for example:

defmodule MyApp.Resilience do
  use Rexsilient

  alias Rexsilient.CircuitBreaker.{Recover, Strategy}

  circuit_breaker :payments do
    strategy Strategy.Count, threshold: 5
    recover Recover.BasicTimeout,
      reset_timeout: :timer.seconds(30),
      probing_timeout: :timer.seconds(10)
  end
end

add it to your supervision tree

children = [
  {Rexsilient, modules: [MyApp.Resilience]},
  MyAppWeb.Endpoint
]

and finally use a decorator to call

defmodule MyApp.Payments do
  use Rexsilient.Decorator

  @circuit_breaker :payments
  def charge(order) do
    PaymentsClient.charge(order)
  end
end

Would love to hear any feedback or idea :slight_smile:

5 Likes