partisan_peer_service (partisan v6.3.0)

View Source

This modules implements the Peer Service API. All functions in this module forward the invocation to the configured peer service manager (option peer_service_manager) which must be one of the Partisan's managers implementing partisan_peer_service_manager, i.e. one of:

  • partisan_pluggable_peer_service_manager
  • partisan_client_server_peer_service_manager
  • partisan_hyparview_peer_service_manager
  • partisan_static_peer_service_manager

Each node running Partisan listens for connections on a particular IP address and port. This is the information that is required when other nodes wish to join this node.

Summary

Functions

Joins every node specification in Members that is not yet a member, leaving the manager to decide how (the pluggable manager joins it, the HyParView one treats the list as an exchange). Never removes a member: a member absent from Members is unaffected. A member only ever leaves the cluster through leave/0 or leave/1.

Adds a supervised callback to receive peer service membership updates.

Returns the broadcast servers view of full cluster membership. Wait indefinitely for a response is returned from the process.

Returns the broadcast servers view of full cluster membership. Waits Timeout ms for a response from the server.

cancel exchanges started by this node.

Return peer service connections

Decode peer_service_manager state from an encoded form

return a list of exchanges, started by broadcast on thisnode, that are running.

returns a list of exchanges, started by broadcast on Node, that are running.

Inject a partition.

Leave the cluster.

Remove a node from the cluster.

Return current peer service manager for this

Return a sampling of nodes connected to this node. When using a full-mesh topology i.e. partisan_pluggable_peer_service_manager or partisan_static_peer_service_manager this is the set of all cluster members. However, if you're using other managers, the result will only be a sampling of the nodes.

Return cluster members

Return cluster members

Trigger function on connection close for a given node. Function 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. Function 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. Function 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. Function is a function object taking zero or a single argument, where the argument is the Node name.

Reserve a slot for the particular tag.

Resolve a partition.

Stop

Replaces the cluster membership with Members: a node specification in the list that is not yet a member is joined, and a member absent from the list leaves the cluster — the removal is gossiped, and the removed node shuts its peer service manager down once the gossip reaches it.

Types

ttl/0

-type ttl() :: non_neg_integer().

Functions

add_members(Members)

-spec add_members(Members :: [partisan:node_spec()]) -> ok | {error, not_implemented}.

Joins every node specification in Members that is not yet a member, leaving the manager to decide how (the pluggable manager joins it, the HyParView one treats the list as an exchange). Never removes a member: a member absent from Members is unaffected. A member only ever leaves the cluster through leave/0 or leave/1.

Pinned by partisan_peer_discovery_agent_test and partisan_SUITE:discovery_never_evicts_test/1.

add_sup_callback(Function)

-spec add_sup_callback(fun(([partisan:node_spec()]) -> any())) -> ok.

Adds a supervised callback to receive peer service membership updates.

Deprecated: prefer partisan_membership:subscribe/0 — receive {partisan_membership, Members} in your own process — or poll partisan_membership:members/0. This is a compatibility shim over the membership snapshot's push feed: it spawns a relay process, linked to the caller, that invokes Function with the current member specs on each change. The callback therefore runs asynchronously, in its own process: it does not block the membership path, and one that crashes does not affect others.

broadcast_members()

-spec broadcast_members() -> ordsets:ordset(node()).

Returns the broadcast servers view of full cluster membership. Wait indefinitely for a response is returned from the process.

broadcast_members(Timeout)

-spec broadcast_members(infinity | pos_integer()) -> ordsets:ordset(node()).

Returns the broadcast servers view of full cluster membership. Waits Timeout ms for a response from the server.

cancel_exchanges(WhichExchanges)

cancel exchanges started by this node.

connections()

Return peer service connections

decode(State)

-spec decode(term()) -> term().

Decode peer_service_manager state from an encoded form

exchanges()

-spec exchanges() -> partisan_plumtree_broadcast:exchanges() | no_return().

return a list of exchanges, started by broadcast on thisnode, that are running.

exchanges(Node)

returns a list of exchanges, started by broadcast on Node, that are running.

get_local_state()

-spec get_local_state() -> term().

inject_partition(Origin, TTL)

-spec inject_partition(partisan:node_spec(), ttl()) -> {ok, reference()} | {error, not_implemented}.

Inject a partition.

join(NodeSpec)

-spec join(partisan:node_spec() | node() | list) -> ok | {error, self_join | any()}.

leave()

-spec leave() -> ok.

Leave the cluster.

leave(NodeSpec)

-spec leave(partisan:node_spec()) -> ok.

Remove a node from the cluster.

manager()

-spec manager() -> module().

Return current peer service manager for this

member(Node)

-spec member(Node :: node() | partisan:node_spec()) -> boolean().

Return a sampling of nodes connected to this node. When using a full-mesh topology i.e. partisan_pluggable_peer_service_manager or partisan_static_peer_service_manager this is the set of all cluster members. However, if you're using other managers, the result will only be a sampling of the nodes.

members()

-spec members() -> {ok, [node()]}.

Return cluster members

members_for_orchestration()

-spec members_for_orchestration() -> {ok, [partisan:node_spec()]}.

Return cluster members

on_down(Node, Function)

-spec on_down(node() | partisan:node_spec() | any | '_', function()) -> ok | {error, not_implemented}.

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

At the moment, this only works when using a full-mesh topology i.e. partisan_pluggable_peer_service_manager or partisan_static_peer_service_manager.

on_down(Node, Function, Opts)

-spec on_down(node() | partisan:node_spec() | any | '_',
              partisan_peer_service_manager:on_event_fun(),
              Opts :: #{channel => partisan:channel()}) ->
                 ok | {error, not_implemented}.

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

At the moment, this only works when using a full-mesh topology i.e. partisan_pluggable_peer_service_manager or partisan_static_peer_service_manager.

on_up(Node, Function)

-spec on_up(node() | partisan:node_spec() | any | '_', partisan_peer_service_manager:on_event_fun()) ->
               ok | {error, not_implemented}.

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

At the moment, this only works when using a full-mesh topology i.e. partisan_pluggable_peer_service_manager or partisan_static_peer_service_manager.

on_up(Node, Function, Opts)

-spec on_up(node() | partisan:node_spec() | any | '_',
            partisan_peer_service_manager:on_event_fun(),
            Opts :: #{channel => partisan:channel()}) ->
               ok | {error, not_implemented}.

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

At the moment, this only works when using a full-mesh topology i.e. partisan_pluggable_peer_service_manager or partisan_static_peer_service_manager.

partitions()

-spec partitions() -> {ok, partisan_peer_service_manager:partitions()} | {error, not_implemented}.

reserve(Tag)

-spec reserve(atom()) -> ok | {error, no_available_slots}.

Reserve a slot for the particular tag.

resolve_partition(Reference)

-spec resolve_partition(reference()) -> ok | {error, not_implemented}.

Resolve a partition.

stop()

Stop

stop(Reason)

Stop

sync_join(NodeSpec)

-spec sync_join(partisan:node_spec()) -> ok | {error, self_join | not_implemented | any()}.

update_members(Members)

-spec update_members(Members :: [partisan:node_spec()]) -> ok | {error, not_implemented}.

Replaces the cluster membership with Members: a node specification in the list that is not yet a member is joined, and a member absent from the list leaves the cluster — the removal is gossiped, and the removed node shuts its peer service manager down once the gossip reaches it.

This is for an external membership authority. A discovery backend must use add_members/1: its answer omits members that are booting or briefly unhealthy, and passing it here evicts them.