View Source partisan_remote_ref (partisan v5.0.0-beta.13)

Remote references are Partisan's representation for remote process identifiers (pid()), registered names and references (reference()).

Distributed Erlang (disterl) will transform the representation of process identifiers, registered names and references when they are sent to a remote node. This is done to disambiguate between remote and local instances. Because Partisan doesn't use disterl it needs to implement this same disambiguation mechanism somehow. As disterl's implementation is done by the BEAM internally and not API is exposed, this module is required to achieve the same result.

representation

Representation

This module provide two representation formats for remote identifiers (in general, "references"): (i) a binary URI and; (ii) a tuple.

The functions in this module will check which format to use by reading the configuration parameter remote_ref_as_uri. If true they will return an URI representation. Otherwise they will return a tuple representation.

URI Representation

URI Padding

Tuple Representation

Link to this section Summary

Functions

Takes an atom Name and a node Node and returns a partisan remote reference.
Checks two refs for identity. Two refs are identical if the are equal or if one is a process reference and the other one is a registered name reference of said process. In the latter case the funcion uses erlang:whereis/1 which means the check can fail if the process has died (and thus is no longer registered).
Returns true if reference Ref is located in node Node.

Link to this section Types

-type encoded_name() :: {encoded_name, list()}.
-type encoded_pid() :: {encoded_pid, list()}.
-type encoded_ref() :: {encoded_ref, list()}.
-type n() :: tuple_ref(encoded_name()) | uri().
-type p() :: tuple_ref(encoded_pid()) | uri().
-type r() :: tuple_ref(encoded_ref()) | uri().
-type t() :: p() | r() | n().
-type target() :: encoded_pid() | encoded_ref() | encoded_name().
-type tuple_ref(T) :: {partisan_remote_ref, node(), T}.
-type uri() :: <<_:64, _:_*8>>.

Link to this section Functions

-spec from_term(pid() | reference() | atom() | {atom(), node()}) -> t() | no_return().
-spec from_term(Name :: atom(), Node :: node()) -> n() | no_return().
Takes an atom Name and a node Node and returns a partisan remote reference.
-spec is_identical(A :: t(), B :: t()) -> boolean().
Checks two refs for identity. Two refs are identical if the are equal or if one is a process reference and the other one is a registered name reference of said process. In the latter case the funcion uses erlang:whereis/1 which means the check can fail if the process has died (and thus is no longer registered).
-spec is_local(Ref :: t()) -> boolean() | no_return().
-spec is_local(Ref :: t(), Node :: node()) -> boolean() | no_return().
Returns true if reference Ref is located in node Node.
-spec is_name(any()) -> boolean().
-spec is_name(Ref :: any(), Name :: atom()) -> boolean().
-spec is_pid(any()) -> boolean().
-spec is_reference(any()) -> boolean().
-spec is_type(any()) -> boolean().
-spec node(Ref :: t()) -> node() | no_return().
-spec nodestring(Ref :: t()) -> binary() | no_return().
-spec target(Ref :: t()) -> target() | no_return().
-spec to_term(t()) -> pid() | reference() | atom() | no_return().