partisan_pluggable_peer_service_manager (partisan v5.0.1)

View Source

This module realises the partisan_peer_service_manager behaviour implementing a peer sampling service with a pluggable overlay topology by delegating the topology definition to a callback module implementing the {partisan_peer_service_strategy} behaviour.

Characteristics

  • Uses TCP/IP.
  • All nodes communicate and maintain connections with all other nodes.
  • Nodes periodically send heartbeat messages. The service considers a node "failed" when it misses X heartbeats.
  • Point-to-point messaging with a single network hop.
  • Eventually consistent membership maintained in a CRDT and replicated using gossip.
  • Scalability limited to hundres of nodes (60-200 nodes).

Summary

Functions

Cast a message to a remote gen_server.

Cast a message to a remote gen_server.

Decode state.

Gensym support for forwarding.

Gensym support for forwarding.

Forward message to registered process on the remote side.

Return local node's view of cluster membership.

Inject a partition.

Attempt to join a remote node.

Leave the cluster.

Remove another node from the cluster.

Returns true if node Node is a member in the membership list. Otherwise returns false.

Return membership list.

Return membership list.

Trigger function on connection close for a given node. Fun is a function object taking zero or a single argument, where the argument is the Node name.

Trigger function on connection close for a given node. Fun is a function object taking zero or a single argument, where the argument is the Node name.

Trigger function on connection open for a given node. Fun is a function object taking zero or a single argument, where the argument is the Node name.

Trigger function on connection open for a given node. Fun is a function object taking zero or a single argument, where the argument is the Node name.

Return partitions.

Receive message from a remote manager.

Reserve a slot for the particular tag.

Resolve a partition.

Send message to a remote peer service manager.

Same as start_link([]).

Attempt to join a remote node.

Update membership.

Types

channel_subs/0

-type channel_subs() :: #{{'_' | node(), partisan:channel()} => on_event_fun()}.

from/0

-type from() :: {pid(), atom()}.

info/0

-type info() ::
          connections | retransmit | periodic | instrumentation | distance | tree_refresh |
          {'EXIT', partisan:any_pid(), any()} |
          {connected, partisan:node_spec(), partisan:channel(), tag(), t()}.

interpos_arg/0

-type interpos_arg() :: {receive_message, node(), any()} | {forward_message, node(), any()}.

interpos_fun/0

-type interpos_fun() :: fun((interpos_arg()) -> interpos_arg()).

interposition_map/1

-type interposition_map(T) :: #{any() => T}.

node_subs/0

-type node_subs() :: #{'_' | node() => on_event_fun()}.

on_event_fun/0

-type on_event_fun() :: partisan_peer_service_manager:on_event_fun().

t/0

-type t() ::
          #state{name :: node(),
                 node_spec :: partisan:node_spec(),
                 actor :: partisan:actor(),
                 vclock :: partisan_vclock:vclock(),
                 members :: [partisan:node_spec()],
                 pending :: [partisan:node_spec()],
                 membership_strategy :: atom(),
                 membership_strategy_state :: term(),
                 leaving :: boolean(),
                 distance_metrics :: map(),
                 sync_joins :: #{partisan:node_spec() => sets:set(from())},
                 out_links :: [term()],
                 down_funs :: node_subs(),
                 channel_down_funs :: channel_subs(),
                 up_funs :: node_subs(),
                 channel_up_funs :: channel_subs(),
                 pre_interposition_funs :: interposition_map(x_interpos_fun()),
                 interposition_funs :: interposition_map(interpos_fun()),
                 post_interposition_funs :: interposition_map(x_interpos_fun())}.

tag/0

-type tag() :: atom().

x_interpos_fun/0

-type x_interpos_fun() :: fun((interpos_arg()) -> ok).

Functions

add_interposition_fun(Name, InterpositionFun)

-spec add_interposition_fun(any(), interpos_fun()) -> ok.

add_post_interposition_fun(Name, PostInterpositionFun)

-spec add_post_interposition_fun(any(), x_interpos_fun()) -> ok.

add_pre_interposition_fun(Name, Fun)

-spec add_pre_interposition_fun(any(), x_interpos_fun()) -> ok.

cast_message(Term, Message)

-spec cast_message(Term :: partisan:any_pid() | partisan:any_name(), Message :: partisan:message()) ->
                      ok.

cast_message(Node, ServerRef, Message)

Cast a message to a remote gen_server.

cast_message(Node, ServerRef, Message, Options)

Cast a message to a remote gen_server.

code_change(OldVsn, State, Extra)

-spec code_change(term() | {down, term()}, t(), term()) -> {ok, t()}.

decode(Membership)

Decode state.

forward_message(Term, Message)

Gensym support for forwarding.

forward_message(PidOrName, Message, Opts)

Gensym support for forwarding.

forward_message(Node, ServerRef, Message, Opts)

Forward message to registered process on the remote side.

get_interposition_funs()

-spec get_interposition_funs() -> interposition_map(interpos_fun()).

get_local_state()

Return local node's view of cluster membership.

get_pre_interposition_funs()

-spec get_pre_interposition_funs() -> interposition_map(x_interpos_fun()).

handle_call(Event, From, State)

handle_cast(Event, State)

-spec handle_cast(term(), t()) -> {noreply, t()} | {stop, normal, t()}.

handle_info(Msg, State)

-spec handle_info(info(), t()) -> {noreply, t()}.

init(_)

-spec init([]) -> {ok, t()}.

inject_partition(Origin, TTL)

Inject a partition.

join(NodeSpec)

Attempt to join a remote node.

leave()

Leave the cluster.

leave(NodeSpec)

Remove another node from the cluster.

maybe_reply_sync_joins(State)

member(Node)

Returns true if node Node is a member in the membership list. Otherwise returns false.

members()

Return membership list.

members_for_orchestration()

Return membership list.

on_down(Arg, Fun)

Trigger function on connection close for a given node. Fun is a function object taking zero or a single argument, where the argument is the Node name.

on_down(Node, Fun, Opts)

Trigger function on connection close for a given node. Fun is a function object taking zero or a single argument, where the argument is the Node name.

on_up(Arg, Fun)

Trigger function on connection open for a given node. Fun is a function object taking zero or a single argument, where the argument is the Node name.

on_up(Node, Fun, Opts)

Trigger function on connection open for a given node. Fun is a function object taking zero or a single argument, where the argument is the Node name.

partitions()

Return partitions.

receive_message(Node, Channel, Cmd)

Receive message from a remote manager.

remove_interposition_fun(Name)

-spec remove_interposition_fun(any()) -> ok.

remove_post_interposition_fun(Name)

-spec remove_post_interposition_fun(any()) -> ok.

remove_pre_interposition_fun(Name)

-spec remove_pre_interposition_fun(any()) -> ok.

reserve(Tag)

Reserve a slot for the particular tag.

resolve_partition(Reference)

Resolve a partition.

send_message(Node, Message)

Send message to a remote peer service manager.

start_link()

-spec start_link() -> {ok, pid()} | ignore | {error, term()}.

Same as start_link([]).

supports_capability(Arg)

-spec supports_capability(Arg :: atom()) -> boolean().

sync_join(NodeSpec)

Attempt to join a remote node.

terminate(Reason, State)

-spec terminate(term(), t()) -> term().

update_members(Members)

Update membership.