Exchange v0.2.5 Exchange.MessageBus behaviour View Source

Behaviour that a message library adapter must implement in order to communicate with the Exchange

Link to this section Summary

Callbacks

The current process subscribes to event of type key

Sends a message with a topic of event and content of payload

Callback to initialize the given message bus adapter and return necessary children.

The current process unsubscribes to event of type key

Link to this section Callbacks

Specs

add_listener(key :: String.t()) :: :error | :ok

The current process subscribes to event of type key

Parameters

  • key: Atom that represents an event
Link to this callback

cast_event(event, payload)

View Source

Specs

cast_event(event :: atom(), payload :: any()) :: nil | :ok

Sends a message with a topic of event and content of payload

Parameters

  • event: Atom that represents a topic
  • payload: Data to send to subscribers

Specs

init() :: {:ok, list()}

Callback to initialize the given message bus adapter and return necessary children.

Specs

remove_listener(key :: String.t()) :: :error | :ok

The current process unsubscribes to event of type key

Parameters

  • key: Atom that represents an event