porter v0.0.1 Porter.Notifier

A notifier that calls the provided callbacks belonging to each handler with an argument in the form of a tuple containing a status of either :ok or :error and a nested tuple containing either the atom :data and some binary output or the atom :exit_status and an exit code.

Summary

Functions

Invoked when the event manager passes an event to the handler. The callback provided to init/1 is then called passing in the event data as the argument

Initialize the Notifier handler by converting the callback in a list to a map

Start a GenEvent manager and returns its pid

Notify the specified event manager of an event

Add an event handler to the specified manager with a function to be called for each event

Functions

handle_event(arg1, state)

Specs

handle_event({atom, {atom, String.t | integer}}, term) :: {:ok, term}

Invoked when the event manager passes an event to the handler. The callback provided to init/1 is then called passing in the event data as the argument.

init(args)

Specs

init([(... -> any)]) :: {:ok, %{callback: (... -> any)}}

Initialize the Notifier handler by converting the callback in a list to a map.

manager()

Specs

manager :: pid

Start a GenEvent manager and returns its pid.

notify(pid, event)

Specs

notify(pid :: pid, event :: {:ok, {atom, String.t | integer}} | {:error, {:exit_status, integer}}) :: :ok

Notify the specified event manager of an event.

subscribe(pid, callback)

Specs

subscribe(pid :: pid, callback :: (... -> any)) :: :ok

Add an event handler to the specified manager with a function to be called for each event.