Expand description
Supervision tree implementation for Sage v2.
This module provides Erlang/OTP-style supervision trees for managing agent lifecycles with automatic restart capabilities.
§Supervision Strategies
- OneForOne: Restart only the failed child
- OneForAll: Restart all children if one fails
- RestForOne: Restart the failed child and all children started after it
§Restart Policies
- Permanent: Always restart, regardless of exit reason
- Transient: Restart only on abnormal termination (error)
- Temporary: Never restart
§Example
ⓘ
use sage_runtime::supervisor::{Supervisor, Strategy, RestartPolicy};
let mut supervisor = Supervisor::new(Strategy::OneForOne, Default::default());
supervisor.add_child("Worker", RestartPolicy::Permanent, || {
sage_runtime::spawn(|mut ctx| async move {
// Agent logic
ctx.emit(())
})
});
supervisor.run().await?;Structs§
- Restart
Config - Configuration for restart intensity limiting (circuit breaker).
- Supervisor
- A supervisor that manages child agents with restart strategies.
Enums§
- Restart
Policy - Restart policy for supervised children.
- Strategy
- Supervision strategy (OTP-inspired).
Type Aliases§
- SpawnFn
- A spawn function that creates an agent and returns its join handle.