partisan_client_server_peer_service_manager (partisan v5.0.2)

View Source

This module realises the partisan_peer_service_manager behaviour implementing client-server topology where clients communicate with a single server and servers form a full-mesh topology.

Characteristics

  • Uses TCP/IP.
  • Client nodes communicate and maintain connections with server nodes. They refuse connections from other clients but refer them to a server node.
  • Server nodes communicate and maintain connections with all other server nodes.
  • Nodes periodically send heartbeat messages. The service considers a node "failed" when it misses X heartbeats.
  • Point-to-point messaging through the server (server as relay).
  • 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.

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 manager.

Same as start_link([]).

Attempt to join a remote node.

Update membership.

Types

call/0

-type call() ::
          {on_up | on_down, node(), on_event_fun()} |
          {reserve, term()} |
          {leave, partisan:node_spec()} |
          {join, partisan:node_spec()} |
          {send_message, node(), term()} |
          {receive_message, partisan:channel(), term()} |
          members | members_for_orchestration | get_local_state.

cast/0

-type cast() :: {join, partisan:node_spec()} | {kill_connections, [node()]}.

membership/0

-type membership() :: sets:set(partisan:node_spec()).

on_event_fun/0

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

pending/0

-type pending() :: sets:set(partisan:node_spec()).

state/0

-type state() ::
          #state{tag :: tag(),
                 pending :: pending(),
                 membership :: membership(),
                 down_functions :: #{'_' | node() => on_event_fun()},
                 up_functions :: #{'_' | node() => on_event_fun()}}.

tag/0

-type tag() :: atom().

Functions

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.

decode(State)

Decode state.

forward_message(Term, Message)

Gensym support for forwarding.

forward_message(Pid, Message, Opts)

Gensym support for forwarding.

forward_message(Node, ServerRef, Message, Opts)

Forward message to registered process on the remote side.

get_local_state()

Return local node's view of cluster membership.

handle_call(Msg, From, State)

-spec handle_call(call(), {pid(), term()}, state()) ->
                     {reply, term(), state()} |
                     {reply, term(), state(), timeout()} |
                     {reply, term(), state(), hibernate} |
                     {reply, term(), state(), {continue, term()}} |
                     {noreply, state()} |
                     {noreply, state(), timeout()} |
                     {noreply, state(), hibernate} |
                     {noreply, state(), {continue, term()}} |
                     {stop, term(), term(), state()} |
                     {stop, term(), state()}.

handle_cast(Msg, State)

-spec handle_cast(cast(), state()) -> {noreply, state()}.

handle_info(Event, State0)

init(_)

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

inject_partition(Origin, TTL)

Inject a partition.

join(Node)

Attempt to join a remote node.

leave()

Leave the cluster.

leave(NodeSpec)

Remove another node from the cluster.

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, O_pts)

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(Peer, Channel, Message)

Receive message from a remote manager.

reserve(Tag)

Reserve a slot for the particular tag.

resolve_partition(Reference)

Resolve a partition.

send_message(Name, Message)

Send message to a remote 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(Node)

Attempt to join a remote node.

update_members(Nodes)

Update membership.