defused v0.1.1 Defused View Source
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.
Examples
use Defused
defused :fuse_name, test(arg) do
case :rand.uniform() < 0.5 do
true -> {:ok, arg}
_ -> {:error, :boom}
end
end
Link to this section Summary
Functions
Defines a fused function with the given fuse name, function name and body
Link to this section Functions
Defines a fused function with the given fuse name, function name and body.
Examples
defmodule Foo do
defused :fuse, bar, do: :ok
end
Foo.bar #=> :ok
Returns
A defused function must return either :ok
or {:ok, _}
, otherwise
the fuse will melt, and eventually blow.
When the fuse is blown, the function will return {:error, :unavailable}