beryl/group
Channel Groups - Named collections of topics for multi-topic broadcasting
Groups let you organize topics and broadcast to all of them at once. Useful for scenarios like broadcasting to all channels in a "team" or sending a system-wide notification.
When running beryl under beryl/supervisor, enable groups with
supervisor.with_groups and obtain the handle from supervisor.groups
instead of calling start directly.
Example
Section titled “Example”let assert Ok(groups) = group.start()let assert Ok(Nil) = group.create(groups, "team:engineering")let assert Ok(Nil) = group.add(groups, "team:engineering", "room:frontend")let assert Ok(Nil) = group.add(groups, "team:engineering", "room:backend")group.broadcast(groups, channels, "team:engineering", "announce", payload)GroupError
Section titled “GroupError”Errors from group operations
pub type GroupError { GroupAlreadyExists GroupNotFound}Constructors
Section titled “Constructors”GroupAlreadyExists
Section titled “GroupAlreadyExists”The group already exists
GroupNotFound
Section titled “GroupNotFound”The group was not found
Groups
Section titled “Groups”A running Groups instance.
This handle is intentionally opaque so callers cannot forge the backing actor subject or depend on its runtime representation.
pub type GroupsGroupStartError
Section titled “GroupStartError”Errors when starting the groups actor.
pub type GroupStartError { GroupActorStartFailed(error.StartFailure)}Constructors
Section titled “Constructors”GroupActorStartFailed(error.StartFailure)
Section titled “GroupActorStartFailed(error.StartFailure)”The actor failed to start
Message
Section titled “Message”Messages the groups actor handles
pub type MessageFunctions
Section titled “Functions”Add a topic to a group
Panics if the groups actor is unavailable or does not reply within 5 seconds.
pub fn add( Groups, String, String) -> Result(Nil, GroupError)broadcast
Section titled “broadcast”Broadcast a message to all topics in a group
Sends the message to every topic in the named group via beryl.broadcast(). If the group doesn't exist, this is a silent no-op (fire and forget).
pub fn broadcast( Groups, beryl.Channels, String, String, json.Json) -> Nilcreate
Section titled “create”Create a new named group
Panics if the groups actor is unavailable or does not reply within 5 seconds.
pub fn create( Groups, String) -> Result(Nil, GroupError)delete
Section titled “delete”Delete a group
Panics if the groups actor is unavailable or does not reply within 5 seconds.
pub fn delete( Groups, String) -> Result(Nil, GroupError)list_groups
Section titled “list_groups”List all group names
Panics if the groups actor is unavailable or does not reply within 5 seconds.
pub fn list_groups(Groups) -> List(String)remove
Section titled “remove”Remove a topic from a group
Panics if the groups actor is unavailable or does not reply within 5 seconds.
pub fn remove( Groups, String, String) -> Result(Nil, GroupError)Start the groups actor
pub fn start() -> Result(Groups, GroupStartError)topics
Section titled “topics”Get all topics in a group
Panics if the groups actor is unavailable or does not reply within 5 seconds.
pub fn topics( Groups, String) -> Result(set.Set(String), GroupError)