pub struct ChildSpec {
pub name: ChildName,
pub start: Box<dyn ChildStart>,
pub restart: SupervisionStrategy,
pub shutdown_budget: Budget,
pub depends_on: Vec<ChildName>,
pub registration: NameRegistrationPolicy,
pub start_immediately: bool,
pub required: bool,
}Expand description
Specification for a supervised child.
This is the compiled topology input for the SPORK supervisor builder. It is intentionally explicit: all “ambient” behavior (naming, restart, ordering) is specified in data so that the compiled runtime is deterministic.
Fields§
§name: ChildNameUnique child identifier (stable tie-break key).
start: Box<dyn ChildStart>Start factory (invoked at initial start and on restart).
restart: SupervisionStrategyRestart strategy for this child (Stop/Restart/Escalate).
shutdown_budget: BudgetShutdown/cleanup budget for this child (used during supervisor stop).
depends_on: Vec<ChildName>Explicit dependencies (child names). Used to compute deterministic start order.
registration: NameRegistrationPolicyOptional name registration policy.
start_immediately: boolWhether the child should be started immediately at supervisor boot.
required: boolWhether the child is required (supervisor fails if child can’t start).
Implementations§
Source§impl ChildSpec
impl ChildSpec
Sourcepub fn new<F>(name: impl Into<ChildName>, start: F) -> Selfwhere
F: ChildStart + 'static,
pub fn new<F>(name: impl Into<ChildName>, start: F) -> Selfwhere
F: ChildStart + 'static,
Create a new child spec.
The child is required and start_immediately by default.
Sourcepub fn with_restart(self, restart: SupervisionStrategy) -> Self
pub fn with_restart(self, restart: SupervisionStrategy) -> Self
Set the restart strategy for this child.
Sourcepub fn with_shutdown_budget(self, budget: Budget) -> Self
pub fn with_shutdown_budget(self, budget: Budget) -> Self
Set the shutdown budget for this child.
Sourcepub fn depends_on(self, name: impl Into<ChildName>) -> Self
pub fn depends_on(self, name: impl Into<ChildName>) -> Self
Add a dependency on another child by name.
Sourcepub fn with_registration(self, policy: NameRegistrationPolicy) -> Self
pub fn with_registration(self, policy: NameRegistrationPolicy) -> Self
Set name registration policy for this child.
Sourcepub fn with_start_immediately(self, start: bool) -> Self
pub fn with_start_immediately(self, start: bool) -> Self
Set whether the child should start immediately.
Sourcepub fn with_required(self, required: bool) -> Self
pub fn with_required(self, required: bool) -> Self
Set whether the child is required.
Sourcepub fn spec_eq(&self, other: &Self) -> bool
pub fn spec_eq(&self, other: &Self) -> bool
Compare two child specs by deterministic declarative surface only.
This intentionally ignores the start factory closure and compares
only pure spec fields so builder outputs can be compared in tests and
tooling without depending on closure identity.
Sourcepub fn spec_fingerprint(&self) -> u64
pub fn spec_fingerprint(&self) -> u64
Deterministic fingerprint of the declarative child spec fields.
Like spec_eq, this excludes the start closure and
hashes only pure spec data.