Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/soundtrackyourbrand/defused

A fuse wrapping macro for easy circuit breaking
https://github.com/soundtrackyourbrand/defused

Last synced: about 1 month ago
JSON representation

A fuse wrapping macro for easy circuit breaking

Awesome Lists containing this project

README

        

# Defused

[![Build Status](https://travis-ci.org/soundtrackyourbrand/defused.svg?branch=master)](https://travis-ci.org/soundtrackyourbrand/defused)
[![Inline docs](http://inch-ci.org/github/soundtrackyourbrand/defused.svg)](http://inch-ci.org/github/soundtrackyourbrand/defused)

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](http://hexdocs.pm/defused/).

# Usage

You first need to install a fuse, see [fuse source](https://github.com/jlouis/fuse)

```elixir
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

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