pub struct TreeShutdownPolicy {
pub budget: ShutdownBudget,
pub abort_after_timeout: bool,
pub force_kill_margin: Duration,
pub max_orphan_threshold: u32,
}Expand description
Shutdown timing policy for a supervisor tree.
Fields§
§budget: ShutdownBudgetDefault cooperative stop budget inherited by children without an override.
abort_after_timeout: boolWhether asynchronous stragglers may be aborted after the timeout.
force_kill_margin: DurationExtra grace beyond the tree budget before the global hard deadline.
max_orphan_threshold: u32Maximum orphaned child tasks before controlled process exit.
When set to 0, the threshold is computed automatically from worker count.
Implementations§
Source§impl TreeShutdownPolicy
impl TreeShutdownPolicy
Sourcepub fn effective_global_deadline(&self) -> Duration
pub fn effective_global_deadline(&self) -> Duration
Returns the total duration budget for the global shutdown hard
deadline: budget.graceful_timeout + budget.abort_wait + force_kill_margin.
§Arguments
This function has no arguments.
§Returns
Returns the total Duration.
§Examples
use std::time::Duration;
use rust_supervisor::spec::shutdown::{ShutdownBudget, TreeShutdownPolicy};
let policy = TreeShutdownPolicy::new(
ShutdownBudget::new(Duration::from_secs(5), Duration::from_secs(1)),
true,
Duration::from_secs(5),
0,
);
assert_eq!(
policy.effective_global_deadline(),
Duration::from_secs(11),
);Sourcepub fn effective_max_orphan_threshold(&self) -> u32
pub fn effective_max_orphan_threshold(&self) -> u32
Source§impl TreeShutdownPolicy
impl TreeShutdownPolicy
Sourcepub fn new(
budget: ShutdownBudget,
abort_after_timeout: bool,
force_kill_margin: Duration,
max_orphan_threshold: u32,
) -> Self
pub fn new( budget: ShutdownBudget, abort_after_timeout: bool, force_kill_margin: Duration, max_orphan_threshold: u32, ) -> Self
Creates a tree shutdown policy.
§Arguments
budget: Default cooperative stop budget for the tree.abort_after_timeout: Whether async stragglers may be aborted.force_kill_margin: Extra grace before the global hard deadline.max_orphan_threshold: Max orphan count before process exit. Pass 0 to compute automatically.
§Returns
Returns a TreeShutdownPolicy.
Sourcepub fn with_budget(budget: ShutdownBudget) -> Self
pub fn with_budget(budget: ShutdownBudget) -> Self
Creates a tree policy from one budget and recommended tree defaults.
§Arguments
budget: Default cooperative stop budget for the tree.
§Returns
Returns a TreeShutdownPolicy with abort enabled and automatic orphan threshold.
Trait Implementations§
Source§impl Clone for TreeShutdownPolicy
impl Clone for TreeShutdownPolicy
Source§fn clone(&self) -> TreeShutdownPolicy
fn clone(&self) -> TreeShutdownPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TreeShutdownPolicy
Source§impl Debug for TreeShutdownPolicy
impl Debug for TreeShutdownPolicy
Source§impl Default for TreeShutdownPolicy
impl Default for TreeShutdownPolicy
Source§impl<'de> Deserialize<'de> for TreeShutdownPolicy
impl<'de> Deserialize<'de> for TreeShutdownPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for TreeShutdownPolicy
Source§impl JsonSchema for TreeShutdownPolicy
impl JsonSchema for TreeShutdownPolicy
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for TreeShutdownPolicy
impl PartialEq for TreeShutdownPolicy
Source§fn eq(&self, other: &TreeShutdownPolicy) -> bool
fn eq(&self, other: &TreeShutdownPolicy) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for TreeShutdownPolicy
impl Serialize for TreeShutdownPolicy
impl StructuralPartialEq for TreeShutdownPolicy
Auto Trait Implementations§
impl Freeze for TreeShutdownPolicy
impl RefUnwindSafe for TreeShutdownPolicy
impl Send for TreeShutdownPolicy
impl Sync for TreeShutdownPolicy
impl Unpin for TreeShutdownPolicy
impl UnsafeUnpin for TreeShutdownPolicy
impl UnwindSafe for TreeShutdownPolicy
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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);