Search documentation of macula

# macula_membership_list (macula v0.44.2)

View Source

Membership list for SWIM protocol. Maintains cluster membership view with fast concurrent access. Uses map-based storage (could be ETS in production).

# Summary

## Types

member_list/0

## Functions

add_member(List, Member)

Add a new member to the list. If member already exists, this is a no-op (use update_member instead).

get_alive_members(_)

Get all alive members.

get_all_members(_)

Get all members.

get_member(_, NodeId)

Get a member by node ID.

get_random_members(List, N)

Get N random members from the list.

get_random_members(_, N, ExcludeNodeId)

Get N random members excluding specified node ID.

get_suspect_members(_)

Get all suspect members.

new(LocalMember)

Create a new membership list with the local node.

remove_member(List, NodeId)

Remove a member from the list.

size(_)

Get the number of members in the list.

update_member(List, NewMember)

Update an existing member (or add if not present). Uses merge semantics to resolve conflicts.

# Types

# member_list/0

    -type member_list() :: #{members := #{binary() => macula_membership_member:member()}}.

# Functions

# add_member(List, Member)

    -spec add_member(member_list(), macula_membership_member:member()) -> member_list().

Add a new member to the list. If member already exists, this is a no-op (use update_member instead).

# get_alive_members(_)

    -spec get_alive_members(member_list()) -> [macula_membership_member:member()].

Get all alive members.

# get_all_members(_)

    -spec get_all_members(member_list()) -> [macula_membership_member:member()].

Get all members.

# get_member(_, NodeId)

    -spec get_member(member_list(), binary()) -> {ok, macula_membership_member:member()} | not_found.

Get a member by node ID.

# get_random_members(List, N)

    -spec get_random_members(member_list(), pos_integer()) -> [macula_membership_member:member()].

Get N random members from the list.

# get_random_members(_, N, ExcludeNodeId)

    -spec get_random_members(member_list(), pos_integer(), binary() | undefined) ->
                                [macula_membership_member:member()].

Get N random members excluding specified node ID.

# get_suspect_members(_)

    -spec get_suspect_members(member_list()) -> [macula_membership_member:member()].

Get all suspect members.

# new(LocalMember)

    -spec new(macula_membership_member:member()) -> member_list().

Create a new membership list with the local node.

# remove_member(List, NodeId)

    -spec remove_member(member_list(), binary()) -> member_list().

Remove a member from the list.

# size(_)

    -spec size(member_list()) -> non_neg_integer().

Get the number of members in the list.

# update_member(List, NewMember)

    -spec update_member(member_list(), macula_membership_member:member()) -> member_list().

Update an existing member (or add if not present). Uses merge semantics to resolve conflicts.