View Source ebus_ps (ebus v0.3.0)
Phoenix.PubSub module. Copyright (c) 2014 Chris McCord
Link to this section Summary
Functions
Broadcasts message on given topic.
Broadcasts message to all but
FromPid on given topic.Returns the topic list. This is an expensive and private operation. DO NOT USE IT IN PROD.
Equivalent to subscribe(Server, Pid, Topic, []).
Subscribes the pid to the PubSub adapter's topic.
Returns a set of subscribers pids for the given topic.
Unsubscribes the pid from the PubSub adapter's topic.
Link to this section Types
-type options() :: ebus_ps_local:options().
Link to this section Functions
-spec broadcast(atom(), binary(), term()) -> ok | {error, term()}.
-spec broadcast_from(atom(), pid(), binary(), term()) -> ok | {error, term()}.
FromPid on given topic.
-spec list(atom()) -> [binary()].
Equivalent to subscribe(Server, Pid, Topic, []).
-spec subscribe(atom(), pid(), binary(), options()) -> ok | {error, term()}.
Subscribes the pid to the PubSub adapter's topic.
Server: The Pid registered name of the server.Pid: The subscriber pid to receive pubsub messages.Topic: The topic to subscribe to, ie:"users:123".Opts: The optional list of options. See below.
link: links the subscriber to the pubsub adapter.fastlane: Provides a fastlane path for the broadcasts forbroadcast()events. The fastlane process is notified of a cached message instead of the normal subscriber. Fastlane handlers must implementfastlane/1callbacks which accepts abroadcast()struct and returns a fastlaned format for the handler. For example:
ebus_ps:subscribe(
my_pubsub_server, self(), <<"topic1">>,
[{fastlane, {FastPid, my_serializer, [<<"event1">>]}).`
-spec subscribers(atom(), binary()) -> [pid()].
Returns a set of subscribers pids for the given topic.
Server: The registered server name or pid.Topic: The string topic, for example<<"users:123">>.
Example:
> subscribers(pubsub_server, <<"foo">>).
[<0.48.0>, <0.49.0>]
-spec unsubscribe(atom(), pid(), binary()) -> ok | {error, term()}.