pub struct SupervisorSpec {Show 16 fields
pub path: SupervisorPath,
pub strategy: SupervisionStrategy,
pub children: Vec<ChildSpec>,
pub config_version: String,
pub default_restart_policy: RestartPolicy,
pub default_backoff_policy: BackoffPolicy,
pub default_health_policy: HealthPolicy,
pub default_shutdown_policy: ShutdownPolicy,
pub supervisor_failure_limit: u32,
pub restart_budget: Option<RestartBudget>,
pub escalation_policy: Option<EscalationPolicy>,
pub group_strategies: Vec<GroupStrategy>,
pub child_strategy_overrides: Vec<ChildStrategyOverride>,
pub dynamic_supervisor_policy: DynamicSupervisorPolicy,
pub control_channel_capacity: usize,
pub event_channel_capacity: usize,
}Expand description
Declarative specification for one supervisor node.
Fields§
§path: SupervisorPathStable path for this supervisor.
strategy: SupervisionStrategyRestart scope strategy for child exits.
children: Vec<ChildSpec>Children in declaration order.
config_version: StringConfiguration version that produced this declaration.
default_restart_policy: RestartPolicyRestart policy inherited by children that do not override it.
default_backoff_policy: BackoffPolicyBackoff policy inherited by children that do not override it.
default_health_policy: HealthPolicyHealth policy inherited by children that do not override it.
default_shutdown_policy: ShutdownPolicyShutdown policy inherited by children that do not override it.
supervisor_failure_limit: u32Maximum supervisor failures before parent escalation.
restart_budget: Option<RestartBudget>Optional supervisor-level restart budget.
escalation_policy: Option<EscalationPolicy>Optional supervisor-level escalation policy.
group_strategies: Vec<GroupStrategy>Group-level strategy overrides.
child_strategy_overrides: Vec<ChildStrategyOverride>Child-level strategy overrides.
dynamic_supervisor_policy: DynamicSupervisorPolicyRuntime policy for dynamic child additions.
control_channel_capacity: usizeControl command channel capacity.
event_channel_capacity: usizeEvent broadcast channel capacity.
Implementations§
Source§impl SupervisorSpec
impl SupervisorSpec
Sourcepub fn root(children: Vec<ChildSpec>) -> Self
pub fn root(children: Vec<ChildSpec>) -> Self
Creates a root supervisor specification.
§Arguments
children: Children declared under the root supervisor.
§Returns
Returns a root SupervisorSpec with declaration-order children.
§Examples
let spec = rust_supervisor::spec::supervisor::SupervisorSpec::root(Vec::new());
assert_eq!(spec.path.to_string(), "/");Examples found in repository?
25fn main() -> ExampleResult {
26 // Build the market feed child.
27 let mut market_feed = worker("market_feed", "Market Feed");
28 // Add low-cardinality market feed tags.
29 market_feed.tags = vec!["market".to_owned(), "network".to_owned()];
30 // Require explicit readiness for the market feed.
31 market_feed.readiness_policy = ReadinessPolicy::Explicit;
32
33 // Build the risk engine child.
34 let mut risk_engine = worker("risk_engine", "Risk Engine");
35 // Make the risk engine depend on the market feed.
36 risk_engine.dependencies = vec![market_feed.id.clone()];
37 // Add low-cardinality risk engine tags.
38 risk_engine.tags = vec!["risk".to_owned()];
39
40 // Build the audit sink child.
41 let mut audit_sink = worker("audit_sink", "Audit Sink");
42 // Mark the audit sink as optional.
43 audit_sink.criticality = Criticality::Optional;
44 // Add low-cardinality audit tags.
45 audit_sink.tags = vec!["audit".to_owned()];
46
47 // Build the root supervisor specification.
48 let mut spec = SupervisorSpec::root(vec![market_feed.clone(), risk_engine, audit_sink]);
49 // Select the RestForOne restart strategy.
50 spec.strategy = SupervisionStrategy::RestForOne;
51 // Set an example configuration version.
52 spec.config_version = "examples-supervisor-tree-story".to_owned();
53
54 // Build the indexed supervisor tree.
55 let tree = SupervisorTree::build(&spec)?;
56 // Print the root supervisor path.
57 println!("root_path={}", tree.root_path);
58 // Print startup order by child name.
59 println!("startup_order={:?}", child_names(startup_order(&tree)));
60 // Print shutdown order by child name.
61 println!("shutdown_order={:?}", child_names(shutdown_order(&tree)));
62 // Print the restart scope after market feed failure.
63 println!(
64 // Provide the output template.
65 "restart_scope_after_market_feed={:?}",
66 // Calculate the restart scope.
67 restart_scope(&tree, spec.strategy, &market_feed.id),
68 // Finish printing the restart scope.
69 );
70
71 // Finish the example successfully.
72 Ok(())
73 // End the supervisor tree example.
74}Trait Implementations§
Source§impl Clone for SupervisorSpec
impl Clone for SupervisorSpec
Source§fn clone(&self) -> SupervisorSpec
fn clone(&self) -> SupervisorSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SupervisorSpec
impl !RefUnwindSafe for SupervisorSpec
impl Send for SupervisorSpec
impl Sync for SupervisorSpec
impl Unpin for SupervisorSpec
impl UnsafeUnpin for SupervisorSpec
impl !UnwindSafe for SupervisorSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);