hare v0.2.2 Hare.Context.Action behaviour

This module defines the behaviour all actions must implement to be run as a step in a context.

Default actions

The following common actions are implemented by default and can be referenced with an atom instead of the whole module name:

  • declare_exchange - (Action.DeclareExchange) declares an exchange
  • exchange - (Action.DeclareExchange) alias for :declare_exchange
  • default_exchange - (Action.DefaultExchange) noop to produce the default exchange
  • delete_exchange - (Action.DeleteExchange) deletes an exchange
  • declare_queue - (Action.DeclareQueue) declares a queue
  • queue - (Action.DeclareQueue) alias for :declare_queue
  • delete_queue - (Action.DeleteQueue) deletes a queue
  • declare_server_named_queue - (Action.DeclareServerNamedQueue) declares a server-named queue
  • server_named_queue - (Action.DeclareServerNamedQueue) alias for :declare_server_named_queue
  • bind - (Action.Bind) binds a queue to an exchange
  • unbind - (Action.Unbind) unbinds a queue from an exchange

Check each action module for more information about its configuration format.

Summary

Types

The configuration of an action

A map containing the data exported from previously executed steps

Information about the execution of an action

t()

Callbacks

Runs the action

Validates the given config format

Types

config()
config() :: Keyword.t

The configuration of an action

exports()
exports() :: map

A map containing the data exported from previously executed steps

info()
info() :: term

Information about the execution of an action

t()
t() :: module | atom

Callbacks

run(chan, config, exports)
run(chan :: Hare.Core.Chan.t, config, exports) ::
  :ok |
  {:ok, info} |
  {:ok, info, exports} |
  {:error, reason :: term}

Runs the action.

It receives a open AMQP channel, the config of the action, and the exports map, containing data from previous run actions.

It may return 4 possible values:

  • :ok - On success (info is %{} by default)
  • {:ok, info} - On success, providing some info about the execution of the step
  • {:ok, info, exports} - On success, providing some info, with a modified exports map
  • {:error, reason} - On error
validate(config)
validate(config) :: :ok | {:error, reason :: term}

Validates the given config format.

It must return :ok if config is valid, and {:error, reason} if it is invalid.