View Source ebus_ps_local (ebus v0.3.0)
Phoenix.PubSub.Local module. Copyright (c) 2014 Chris McCord
Link to this section Summary
Functions
Sends a message to all subscribers of a topic.
Returns the topic list for all local shards.
Returns the topic list for the given shard.
Starts the server.
Subscribes the pid to the topic.
Returns a set of subscribers pids for the given topic.
See also: subscribers/3.
See also: subscribers_by_shard/3.
Returns a list of topics which Pid is subscribed.
Unsubscribes the pid from the topic.
Link to this section Types
Link to this section Functions
-spec broadcast(atom(), pos_integer(), pid(), binary(), term()) -> ok.
Sends a message to all subscribers of a topic.
Server: The registered server name or pid.Topic: The string topic, for example<<"users:123">>.
Examples:
> broadcast(pubsub_server, self(), <<"foo">>).
ok
> broadcast(pubsub_server, none, <<"bar">>).
ok
-spec gc_name(atom(), non_neg_integer()) -> atom().
-spec list(atom(), pos_integer()) -> [binary()].
Returns the topic list for all local shards.
This is an expensive operation. DO NOT USE IT IN PROD
-spec list_by_shard(atom(), non_neg_integer()) -> [binary()].
Returns the topic list for the given shard.
This is an expensive operation. DO NOT USE IT IN PROD
-spec local_name(atom(), non_neg_integer()) -> atom().
-spec start_link(atom(), atom()) -> gen_server:start_ret().
Starts the server.
ServerName: The name to register the server under.
Equivalent to subscribe(Server, PoolSize, Pid, Topic, []).
-spec subscribe(atom(), pos_integer(), pid(), binary(), options()) -> ok.
Subscribes the pid to the 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.
Examples:
> subscribe(pubsub_server, self(), <<"foo">>, []).
ok
> subscribe(pubsub_server, self(), <<"foo">>,
[{fastlane, {FastPid, my_serializer, [<<"event1">>]}]).
ok
-spec subscribers(atom(), pos_integer(), 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">>.
Examples:
> subscribers(pubsub_server, <<"foo">>).
[<0.48.0>, <0.49.0>]
-spec subscribers_by_shard(atom(), binary(), non_neg_integer()) -> [pid()].
See also: subscribers/3.
-spec subscribers_with_fastlanes(atom(), binary(), non_neg_integer()) -> [{pid(), nil | term()}].
See also: subscribers_by_shard/3.
-spec subscription(atom(), non_neg_integer(), pid()) -> [binary()].
Returns a list of topics which Pid is subscribed.
This is an expensive operation. DO NOT USE IT IN PROD
-spec unsubscribe(atom(), pos_integer(), pid(), binary()) -> ok.
Unsubscribes the pid from the topic.
Server: The registered server name or pid.Pid: The subscriber pid.Topic: The string topic, for example<<"users:123">>.
Example:
> unsubscribe(pubsub_server, self(), <<"foo">>).
ok