hare v0.2.2 Hare.Context.Action.DefaultExchange

This module implements a Hare.Context.Action behaviour to build the default exchange.

This action do not interact with the AMQP server, but provides an easy way to build the default exchange and export it, in order to be used by other steps or by the caller of the context.

Config

Configuration must be a Keyword.t with the following fields:

  • :export_as - (defaults to nil) the key to export the declared exchange to

The :export_as config allows the action to export a Hare.Core.Exchange struct to be used later by other steps.

alias Hare.Context.Action.DefaultExchange

config  = [export_as: :def]
exports = %{}

DefaultExchange.run(chan, config, exports)
# => {:ok, nil, %{def: %Hare.Core.Exchange{chan: chan, name: ""}}}

Summary

Types

The action configuration

Functions

Runs the action

Validates the given config format

Types

config()
config() :: [name: binary, type: atom, opts: Keyword.t, export_as: atom]

The action configuration

Functions

run(chan, config, exports)

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

Callback implementation for Hare.Context.Action.run/3.

validate(config)

Validates the given config format.

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

Callback implementation for Hare.Context.Action.validate/1.