Module ebus_ps_local

This is an Erlang clone of the original Phoenix.PubSub.Local module.

Behaviours: gen_server.

References

Description

This is an Erlang clone of the original Phoenix.PubSub.Local module. Copyright (c) 2014 Chris McCord

Data Types

fastlane()

fastlane() = {FastlanePid::pid(), Serializer::module(), EventIntercepts::[term()]}

Fastlane definition.

option()

option() = {link, any()} | {fastlane, fastlane()}

subscribe/5 function options.

options()

options() = [option()]

Function Index

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/4Equivalent 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.

Function Details

broadcast/5

broadcast(Server::atom(), PoolSize::pos_integer(), From::pid(), Topic::binary(), Msg::term()) -> ok

Sends a message to all subscribers of a topic.

Examples:

  > broadcast(pubsub_server, self(), <<"foo">>).
  ok
  > broadcast(pubsub_server, none, <<"bar">>).
  ok

gc_name/2

gc_name(Server::atom(), Shard::non_neg_integer()) -> atom()

list/2

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/2

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/2

local_name(Server::atom(), Shard::non_neg_integer()) -> atom()

start_link/2

start_link(ServerName::atom(), GCName::atom()) -> gen:start_ret()

Starts the server.

subscribe/4

subscribe(Server, PoolSize, Pid, Topic) -> any()

Equivalent to subscribe(Server, PoolSize, Pid, Topic, []).

subscribe/5

subscribe(Server::atom(), PoolSize::pos_integer(), Pid::pid(), Topic::binary(), Opts::options()) -> ok

Subscribes the pid to the topic.

Options:

Examples:

  > subscribe(pubsub_server, self(), <<"foo">>, []).
  ok
  > subscribe(pubsub_server, self(), <<"foo">>,
      [{fastlane, {FastPid, my_serializer, [<<"event1">>]}]).
  ok

subscribers/3

subscribers(Server::atom(), PoolSize::pos_integer(), Topic::binary()) -> [pid()]

Returns a set of subscribers pids for the given topic.

Examples:

  > subscribers(pubsub_server, <<"foo">>).
  [<0.48.0>, <0.49.0>]

subscribers_by_shard/3

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/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/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/4

unsubscribe(Server::atom(), PoolSize::pos_integer(), Pid::pid(), Topic::binary()) -> ok

Unsubscribes the pid from the topic.

Example:

  > unsubscribe(pubsub_server, self(), <<"foo">>).
  ok


Generated by EDoc