greyhound v0.1.0 Greyhound.TestBus

Link to this section Summary

Functions

Returns a list of middleware modules that implement the Greyhound.Middleware callbacks

Emits an event for processing

Subscribes the current process to a topic

Returns a list of processes subscribed to a topic

Unsubscribes the current process from a topic

Link to this section Functions

Link to this function __middleware__()
__middleware__() :: [module()]

Returns a list of middleware modules that implement the Greyhound.Middleware callbacks.

Override this function if a different set of middleware is required.

Link to this function dispatch(topic, message)
dispatch(binary(), term()) :: :ok | {:error, :not_started}

Emits an event for processing.

Events are processed using middleware. See Greyhound.Middleware for more details.

Example

iex> Elixir.Greyhound.TestBus.dispatch("a_topic", "a message")
:ok
Link to this function start_link(opts)
start_link(Keyword.t()) :: Supervisor.on_start()
Link to this function subscribe(topic)
subscribe(binary()) :: :ok | {:error, :not_started}

Subscribes the current process to a topic.

Example

iex> Elixir.Greyhound.TestBus.subscribe("a_topic")
:ok
Link to this function subscribers(topic)
subscribers(binary()) :: :ok | {:error, :not_started}

Returns a list of processes subscribed to a topic.

Example

iex> Elixir.Greyhound.TestBus.subscribers("a topic")
[#PID<0.173.0>, #PID<0.174.0>, #PID<0.175.0>]
Link to this function unsubscribe(topic)
unsubscribe(binary()) :: :ok | {:error, :not_started}

Unsubscribes the current process from a topic.

Example

iex> Elixir.Greyhound.TestBus.unsubscribe("a_topic")
:ok