soundtrackyourbrand / defused

A fuse wrapping macro for easy circuit breaking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Defused

Build Status Inline docs

Provides a defused/3 macro similar to Kernel#def/2 but that wraps all calls to the provided function body in a call to the specified fuse that will check and blow the fuse as needed.

Documentation for Defused is available online.

Usage

You first need to install a fuse, see fuse source

defmodule MyModule do
  use Defused

  defused :fuse_name, test(arg) do
    case :rand.uniform() < 0.5 do
      true -> {:ok, arg}
      _ -> {:error, :boom}
    end
  end
end

Installation

Add defused to you dependencies

def deps do
  [{:defused, "~> 0.6.0"}]
end

About

A fuse wrapping macro for easy circuit breaking

License:MIT License


Languages

Language:Elixir 100.0%