greyhound v0.1.0 Greyhound

Link to this section Summary

Functions

Emits an event for processing

Subscribe a listener to a topic

Returns a list of processes subscribed to a topic

Unsubscribe a listener from a topic

Link to this section Functions

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

Emits an event for processing.

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

Example

iex> Greyhound.dispatch(MyApp.Bus, "a_topic", "a message")
:ok
Link to this function subscribe(server, topic, pid)
subscribe(atom(), binary(), pid()) :: :ok | {:error, :not_started}

Subscribe a listener to a topic.

Example

iex> subscribe(MyApp.Bus, "a_topic", self())
:ok
Link to this function subscribers(server, topic)
subscribers(atom(), binary()) :: [pid()] | {:error, :not_started}

Returns a list of processes subscribed to a topic.

Example

iex> subscribers(MyApp.Bus, "a_topic")
[#PID<0.173.0>, #PID<0.174.0>, #PID<0.175.0>]
Link to this function unsubscribe(server, topic, pid)
unsubscribe(atom(), binary(), pid()) :: :ok | {:error, :not_started}

Unsubscribe a listener from a topic.

Example

iex> unsubscribe(MyApp.Bus, "a_topic", self())
:ok