beryl/supervisor
OTP supervision tree for beryl subsystems.
This module does not start processes directly. It builds a supervisor child specification for the application's supervision tree, while stable named subjects let callers construct the subsystem handles before that tree starts.
Example
Section titled “Example”import berylimport beryl/presenceimport beryl/supervisorimport beryl/wireimport gleam/otp/static_supervisor
let beryl = supervisor.config(beryl.config(wire.phoenix_codec())) |> supervisor.with_presence(presence.default_config("node1")) |> supervisor.with_groups()
let assert Ok(_root) = static_supervisor.new(static_supervisor.OneForOne) |> static_supervisor.add(supervisor.start(beryl)) |> static_supervisor.start()
let channels = supervisor.channels(beryl)SupervisedConfig
Section titled “SupervisedConfig”Configuration and stable handles for beryl's supervised subsystems.
Construct it with config, add optional subsystems with the
with_* functions, add start to the application's supervisor,
then use channels, presence, and
groups to access the named processes.
pub type SupervisedConfigFunctions
Section titled “Functions”channels
Section titled “channels”The channels handle for this supervised beryl instance.
Add start to a running application supervisor before using the
handle.
pub fn channels(SupervisedConfig) -> beryl.Channelsconfig
Section titled “config”Configure the beryl supervision subtree.
The coordinator is always included. Presence and groups are opt-in via
with_presence and with_groups.
pub fn config(beryl.Config) -> SupervisedConfiggroups
Section titled “groups”The groups handle, if groups were configured.
pub fn groups(SupervisedConfig) -> option.Option(group.Groups)presence
Section titled “presence”The presence handle, if presence was configured.
pub fn presence(SupervisedConfig) -> option.Option(presence.Presence)Build beryl's supervisor child specification.
Add the returned specification to the application's supervision tree. The subtree isolates the connection limiter from a nested rest-for-one channel supervisor. A coordinator crash therefore restarts its dependent presence and groups processes while preserving registrations and live connection counts.
pub fn start(SupervisedConfig) -> supervision.ChildSpecification(static_supervisor.Supervisor)with_groups
Section titled “with_groups”Enable named channel groups.
pub fn with_groups(SupervisedConfig) -> SupervisedConfigwith_presence
Section titled “with_presence”Enable presence tracking with the given configuration.
pub fn with_presence( SupervisedConfig, presence.Config) -> SupervisedConfig