phoenix_pubsub v1.1.2 Phoenix.Tracker.State View Source
Provides an ORSWOT CRDT.
Link to this section Summary
Functions
Returns the causal context for the set
Compacts a sets causal history
Returns the dize of the delta
Extracts the set's elements from ets into a mergeable list
Returns a list of elements for the topic who belong to an online replica
Returns all elements for the pid
Returns the element matching the pid, topic, and key
Returns a list of elements for the topic who belong to an online replica
Checks if set has a non-empty delta
Adds a new element to the set
Removes all elements from the set for the given pid
Removes an element from the set
Merges two sets, or a delta into a set
Creates a new set for the replica
Returns a list of elements in the set belonging to an online replica
Removes all elements for replicas that are permanently gone
Marks a replica as down in the set and returns left users
Marks a replica as up in the set and returns rejoined users
Resets the set's delta
Performs table lookup for tracked key in the topic
Performs table lookup for tracked elements in the topic
Link to this section Types
clock()
View Source
clock() :: pos_integer()
clock() :: pos_integer()
cloud()
View Source
cloud() :: MapSet.t()
cloud() :: MapSet.t()
clouds() View Source
context() View Source
delta() View Source
ets_id()
View Source
ets_id() :: :ets.tid()
ets_id() :: :ets.tid()
key()
View Source
key() :: term()
key() :: term()
key_meta() View Source
meta()
View Source
meta() :: map()
meta() :: map()
name()
View Source
name() :: term()
name() :: term()
pid_lookup() View Source
tag() View Source
topic()
View Source
topic() :: String.t()
topic() :: String.t()
value() View Source
values() View Source
Link to this section Functions
clocks(state) View Source
Returns the causal context for the set.
compact(state) View Source
Compacts a sets causal history.
Called as needed and after merges.
delta_size(state)
View Source
delta_size(delta()) :: pos_integer()
delta_size(delta()) :: pos_integer()
Returns the dize of the delta.
extract(state, remote_ref, remote_context) View Source
Extracts the set's elements from ets into a mergeable list.
Used when merging two sets.
get_by_key(state, topic, key) View Source
Returns a list of elements for the topic who belong to an online replica.
get_by_pid(state, pid) View Source
Returns all elements for the pid.
get_by_pid(state, pid, topic, key) View Source
Returns the element matching the pid, topic, and key.
get_by_topic(state, topic) View Source
Returns a list of elements for the topic who belong to an online replica.
has_delta?(state) View Source
Checks if set has a non-empty delta.
join(state, pid, topic, key, meta \\ %{}) View Source
Adds a new element to the set.
leave(state, pid) View Source
Removes all elements from the set for the given pid.
leave(state, pid, topic, key) View Source
Removes an element from the set.
merge(local, remote) View Source
Merges two sets, or a delta into a set.
Returns a 3-tuple of the updated set, and the joined and left elements.
Examples
iex> {s1, joined, left} =
Phoenix.Tracker.State.merge(s1, Phoenix.Tracker.State.extract(s2))
{%Phoenix.Tracker.State{}, [...], [...]}
merge_deltas(local, remote) View Source
new(replica, shard_name) View Source
Creates a new set for the replica.
Examples
iex> Phoenix.Tracker.State.new(:replica1)
%Phoenix.Tracker.State{...}
online_list(state) View Source
Returns a list of elements in the set belonging to an online replica.
remove_down_replicas(state, replica) View Source
Removes all elements for replicas that are permanently gone.
replica_down(state, replica) View Source
Marks a replica as down in the set and returns left users.
replica_up(state, replica) View Source
Marks a replica as up in the set and returns rejoined users.
reset_delta(state) View Source
Resets the set's delta.
tracked_key(table, topic, key, down_replicas) View Source
Performs table lookup for tracked key in the topic.
Filters out those present on downed replicas.
tracked_values(table, topic, down_replicas) View Source
Performs table lookup for tracked elements in the topic.
Filters out those present on downed replicas.