glixir/supervisor
Dynamic supervisor support for runtime process management
This module provides a Gleam-friendly interface to Elixir’s DynamicSupervisor, using our Elixir helper module for clean data conversion.
Types
pub type ChildCounts {
ChildCounts(
specs: Int,
active: Int,
supervisors: Int,
workers: Int,
)
}
Constructors
-
ChildCounts( specs: Int, active: Int, supervisors: Int, workers: Int, )
pub type ChildInfoResult {
ChildInfo(
id: dynamic.Dynamic,
child: ChildStatus,
child_type: ChildType,
modules: ChildModules,
)
}
Constructors
-
ChildInfo( id: dynamic.Dynamic, child: ChildStatus, child_type: ChildType, modules: ChildModules, )
pub type ChildOperationError {
Running
Restarting
NotFound
SimpleOneForOne
OtherError(reason: dynamic.Dynamic)
}
Constructors
-
Running
-
Restarting
-
NotFound
-
SimpleOneForOne
-
OtherError(reason: dynamic.Dynamic)
pub type ChildStatus {
ChildPid(pid: process.Pid)
ChildRestarting
ChildUndefined
}
Constructors
-
ChildPid(pid: process.Pid)
-
ChildRestarting
-
ChildUndefined
pub type DeleteChildResult {
DeleteChildOk
DeleteChildError(reason: ChildOperationError)
}
Constructors
-
DeleteChildOk
-
DeleteChildError(reason: ChildOperationError)
pub type DynamicChildResult {
DynamicStartChildOk(pid: process.Pid)
DynamicStartChildError(reason: dynamic.Dynamic)
}
Constructors
-
DynamicStartChildOk(pid: process.Pid)
-
DynamicStartChildError(reason: dynamic.Dynamic)
pub type DynamicSupervisorResult {
DynamicSupervisorOk(pid: process.Pid)
DynamicSupervisorError(reason: dynamic.Dynamic)
}
Constructors
-
DynamicSupervisorOk(pid: process.Pid)
-
DynamicSupervisorError(reason: dynamic.Dynamic)
pub type DynamicTerminateResult {
DynamicTerminateChildOk
DynamicTerminateChildError(reason: dynamic.Dynamic)
}
Constructors
-
DynamicTerminateChildOk
-
DynamicTerminateChildError(reason: dynamic.Dynamic)
pub type RestartChildResult {
RestartChildOk(pid: process.Pid)
RestartChildOkAlreadyStarted(pid: process.Pid)
RestartChildError(reason: ChildOperationError)
}
Constructors
-
RestartChildOk(pid: process.Pid)
-
RestartChildOkAlreadyStarted(pid: process.Pid)
-
RestartChildError(reason: ChildOperationError)
Child restart strategy
pub type RestartStrategy {
Permanent
Temporary
Transient
}
Constructors
-
Permanent
-
Temporary
-
Transient
pub type SimpleChildSpec {
SimpleChildSpec(
id: String,
start_module: atom.Atom,
start_function: atom.Atom,
start_args: List(dynamic.Dynamic),
restart: RestartStrategy,
shutdown_timeout: Int,
child_type: ChildType,
)
}
Constructors
-
SimpleChildSpec( id: String, start_module: atom.Atom, start_function: atom.Atom, start_args: List(dynamic.Dynamic), restart: RestartStrategy, shutdown_timeout: Int, child_type: ChildType, )
Opaque type representing a supervisor process
pub opaque type Supervisor
Errors from supervisor operations
pub type SupervisorError {
StartError(reason: String)
ChildStartError(id: String, reason: String)
ChildNotFound(id: String)
AlreadyStarted(id: String)
InvalidChildSpec(reason: String)
}
Constructors
-
StartError(reason: String)
-
ChildStartError(id: String, reason: String)
-
ChildNotFound(id: String)
-
AlreadyStarted(id: String)
-
InvalidChildSpec(reason: String)
pub type TerminateChildResult {
TerminateChildOk
TerminateChildError(reason: ChildOperationError)
}
Constructors
-
TerminateChildOk
-
TerminateChildError(reason: ChildOperationError)
Values
pub fn child_spec(
id: String,
module: String,
function: String,
args: List(dynamic.Dynamic),
) -> SimpleChildSpec
Create a simple child specification - the easy way to define children
pub fn child_spec_with_restart(
id: String,
module: String,
function: String,
args: List(dynamic.Dynamic),
restart: RestartStrategy,
) -> SimpleChildSpec
Create a child spec with custom restart strategy
pub fn count_dynamic_children(
supervisor: Supervisor,
) -> ChildCounts
Count dynamic children by type and status
pub fn delete_child(
supervisor: Supervisor,
child_id: String,
) -> DeleteChildResult
Delete a child specification from the supervisor
pub fn restart_child(
supervisor: Supervisor,
child_id: String,
) -> RestartChildResult
Restart a child process
pub fn start_dynamic_child(
supervisor: Supervisor,
spec: SimpleChildSpec,
) -> Result(process.Pid, String)
Start a child in a DynamicSupervisor
pub fn start_dynamic_supervisor_named(
name: String,
) -> Result(Supervisor, SupervisorError)
Start a named dynamic supervisor
pub fn start_dynamic_supervisor_simple(
,
) -> Result(Supervisor, SupervisorError)
Start a simple dynamic supervisor with defaults
pub fn terminate_child(
supervisor: Supervisor,
child_id: String,
) -> TerminateChildResult
Terminate a child process
pub fn terminate_dynamic_child(
supervisor: Supervisor,
child_pid: process.Pid,
) -> Result(Nil, String)
Terminate a dynamic child process
pub fn which_dynamic_children(
supervisor: Supervisor,
) -> List(ChildInfoResult)
Get information about all dynamic children