pub struct ServiceLifecycle { /* private fields */ }Expand description
Full lifecycle tracker for a single supervised service.
Wraps the ServicePhase enum with timing data, counters, and
transition validation logic. The supervisor holds one of these per
managed service.
Implementations§
Source§impl ServiceLifecycle
impl ServiceLifecycle
Sourcepub fn new(service_name: impl Into<String>) -> Self
pub fn new(service_name: impl Into<String>) -> Self
Create a new lifecycle tracker in the Starting phase.
Sourcepub fn phase(&self) -> ServicePhase
pub fn phase(&self) -> ServicePhase
Current lifecycle phase.
Sourcepub fn service_name(&self) -> &str
pub fn service_name(&self) -> &str
Service name as configured on construction.
Sourcepub fn time_in_current_phase(&self) -> Duration
pub fn time_in_current_phase(&self) -> Duration
How long the service has been in its current phase.
Sourcepub fn start_count(&self) -> u32
pub fn start_count(&self) -> u32
Total number of times the service has been started.
Sourcepub fn total_failures(&self) -> u32
pub fn total_failures(&self) -> u32
Total failures over the service’s lifetime.
Sourcepub fn last_error(&self) -> Option<&str>
pub fn last_error(&self) -> Option<&str>
The last error message recorded on a failed transition, if any.
Sourcepub fn termination_reason(&self) -> Option<&TerminationReason>
pub fn termination_reason(&self) -> Option<&TerminationReason>
Why the service terminated (only Some when phase is Terminated).
Sourcepub fn cumulative_running_time(&self) -> Duration
pub fn cumulative_running_time(&self) -> Duration
Cumulative wall-clock time spent in the Running phase.
If the service is currently running, includes time up to now.
Sourcepub fn transition_to_running(&mut self) -> Result<(), TransitionError>
pub fn transition_to_running(&mut self) -> Result<(), TransitionError>
Move from Starting to Running.
Sourcepub fn transition_to_backing_off(
&mut self,
error: &str,
backoff_duration: Duration,
) -> Result<(), TransitionError>
pub fn transition_to_backing_off( &mut self, error: &str, backoff_duration: Duration, ) -> Result<(), TransitionError>
Move from Running (or Starting) to BackingOff after a failure.
Sourcepub fn transition_to_restarting(&mut self) -> Result<(), TransitionError>
pub fn transition_to_restarting(&mut self) -> Result<(), TransitionError>
Transition from BackingOff → Starting (retry).
Sourcepub fn transition_to_stopping(&mut self) -> Result<(), TransitionError>
pub fn transition_to_stopping(&mut self) -> Result<(), TransitionError>
Move to Stopping on cancellation — services drain after this.
Sourcepub fn transition_to_terminated(
&mut self,
reason: TerminationReason,
) -> Result<(), TransitionError>
pub fn transition_to_terminated( &mut self, reason: TerminationReason, ) -> Result<(), TransitionError>
Transition to Terminated. Terminal — no further transitions allowed.
Trait Implementations§
Source§impl Clone for ServiceLifecycle
impl Clone for ServiceLifecycle
Source§fn clone(&self) -> ServiceLifecycle
fn clone(&self) -> ServiceLifecycle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more