Phoenix.PubSub.Local
module.
Behaviours: gen_server.
References
Phoenix.PubSub.Local
module.
Copyright (c) 2014 Chris McCord
fastlane() = {FastlanePid::pid(), Serializer::module(), EventIntercepts::[term()]}
Fastlane definition.
option() = {link, any()} | {fastlane, fastlane()}
subscribe/5
function options.
options() = [option()]
broadcast/5 | Sends a message to all subscribers of a topic. |
gc_name/2 | |
list/2 | Returns the topic list for all local shards. |
list_by_shard/2 | Returns the topic list for the given shard. |
local_name/2 | |
start_link/2 | Starts the server. |
subscribe/4 | Equivalent to subscribe(Server, PoolSize, Pid, Topic, []). |
subscribe/5 | Subscribes the pid to the topic. |
subscribers/3 | Returns a set of subscribers pids for the given topic. |
subscribers_by_shard/3 | Returns a set of subscribers pids for the given topic and shard. |
subscribers_with_fastlanes/3 | Returns a set of subscribers pids for the given topic and shard with fastlane tuples. |
subscription/3 |
Returns a list of topics which Pid is subscribed. |
unsubscribe/4 | Unsubscribes the pid from the topic. |
broadcast(Server::atom(), PoolSize::pos_integer(), From::pid(), Topic::binary(), Msg::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
gc_name(Server::atom(), Shard::non_neg_integer()) -> atom()
list(Server::atom(), PoolSize::pos_integer()) -> [binary()]
Returns the topic list for all local shards.
This is an expensive and private operation. DO NOT USE IT IN PROD
list_by_shard(Server::atom(), Shard::non_neg_integer()) -> [binary()]
Returns the topic list for the given shard.
This is an expensive and private operation. DO NOT USE IT IN PROD
local_name(Server::atom(), Shard::non_neg_integer()) -> atom()
start_link(ServerName::atom(), GCName::atom()) -> gen:start_ret()
Starts the server.
ServerName
: The name to register the server under.subscribe(Server, PoolSize, Pid, Topic) -> any()
Equivalent to subscribe(Server, PoolSize, Pid, Topic, []).
subscribe(Server::atom(), PoolSize::pos_integer(), Pid::pid(), Topic::binary(), Opts::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 for
broadcast()
events. The fastlane process is notified of a cached
message instead of the normal subscriber. Fastlane handlers must
implement fastlane/1
callbacks which accepts a broadcast()
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
subscribers(Server::atom(), PoolSize::pos_integer(), Topic::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>]
subscribers_by_shard(Server::atom(), Topic::binary(), Shard::non_neg_integer()) -> [pid()]
Returns a set of subscribers pids for the given topic and shard.
See also: subscribers/3.
subscribers_with_fastlanes(Server::atom(), Topic::binary(), Shard::non_neg_integer()) -> [{pid(), nil | term()}]
Returns a set of subscribers pids for the given topic and shard with fastlane tuples.
See also: subscribers_by_shard/3.
subscription(Server::atom(), PoolSize::non_neg_integer(), Pid::pid()) -> [binary()]
Returns a list of topics which Pid
is subscribed.
This is an expensive and private operation. DO NOT USE IT IN PROD
unsubscribe(Server::atom(), PoolSize::pos_integer(), Pid::pid(), Topic::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
Generated by EDoc