hub v0.2.1 Hub

Pub-sub hub

Subscription is done with a pattern.

Example:

Hub.subscribe(“global”, %{count: count} when count > 42) Hub.publish(“global”, %{count: 45, message: “You rock!”})

Summary

Functions

Publishes the term to all subscribers that matches it Returns the number of subscribers that got the message

Convenience macro for subscribing without the need to unquote the pattern

Subscribes to the quoted pattern in the given channel

Gets a list of all subscribers to a channel

Types

channel()
channel() :: String.t
count()
count() :: pos_integer | :infinity
pattern()
pattern() :: any
subscribe_option()
subscribe_option() :: {:pid, pid} | {:count, count}
subscribe_options()
subscribe_options() :: [subscribe_option]

Functions

publish(channel, term)
publish(channel, any) :: non_neg_integer

Publishes the term to all subscribers that matches it Returns the number of subscribers that got the message

subscribe(channel, pattern, options \\ []) (macro)

Convenience macro for subscribing without the need to unquote the pattern.

example:

Hub.subscribe(“global”, %{count: count} when count > 42)

subscribe_quoted(channel, quoted_pattern, options \\ [])
subscribe_quoted(channel, pattern, subscribe_options) :: :ok

Subscribes to the quoted pattern in the given channel

example:

Hub.subscribe(“global”, quote do: %{count: count} when count > 42)

subscribers(channel)
subscribers(channel) :: [Hub.Subscriber.t]

Gets a list of all subscribers to a channel

traverse_pin(term, bindings)