distribute/groups

Types

Process groups for pub/sub and worker pools.

This module wraps Erlang’s :pg (process groups) module to provide cluster-wide process grouping with join/leave/broadcast semantics.

Groups are distributed and eventually consistent. Processes can join multiple groups, and groups can span multiple nodes.

pub type GroupError {
  GroupFailed(String)
}

Constructors

  • GroupFailed(String)

    A group operation failed (e.g. invalid group name or internal error).

pub type Pid

Values

pub fn broadcast(
  group: String,
  msg: a,
) -> Result(Nil, GroupError)

Broadcast a message to all members of a group.

pub fn join(group: String, pid: Pid) -> Result(Nil, GroupError)

Join a process to a named group.

pub fn leave(group: String, pid: Pid) -> Result(Nil, GroupError)

Remove a process from a named group.

pub fn members(group: String) -> List(Pid)

Get the list of member pids in a group.

Search Document