pub struct InstanceLife {
pub state: LifecycleState,
pub since_ms: u64,
pub misses: u32,
pub restarts: Vec<u64>,
pub last_poll_ms: u64,
}Expand description
One instance’s life on one side of the wire.
Fields§
§state: LifecycleStateCurrent state.
since_ms: u64When it entered the state (ms).
misses: u32Consecutive bad polls.
restarts: Vec<u64>Times of the restarts still inside the window (ms, ascending).
last_poll_ms: u64When the last poll happened (ms); 0 before the first.
Implementations§
Source§impl InstanceLife
impl InstanceLife
Sourcepub fn new(state: LifecycleState, now_ms: u64) -> Self
pub fn new(state: LifecycleState, now_ms: u64) -> Self
A new life in state.
Sourcepub fn transition(
&mut self,
to: LifecycleState,
now_ms: u64,
) -> Result<LifecycleState, IllegalTransition>
pub fn transition( &mut self, to: LifecycleState, now_ms: u64, ) -> Result<LifecycleState, IllegalTransition>
Take a legal step (the miss count resets on entering Running).
Sourcepub fn restart_decision(
&self,
policy: &RestartPolicy,
now_ms: u64,
) -> RestartDecision
pub fn restart_decision( &self, policy: &RestartPolicy, now_ms: u64, ) -> RestartDecision
Whether policy allows a restart at now_ms. Restarts older than
the window no longer count. Does not record anything.
Sourcepub fn record_restart(&mut self, policy: &RestartPolicy, now_ms: u64)
pub fn record_restart(&mut self, policy: &RestartPolicy, now_ms: u64)
Record a restart at now_ms (and forget those outside the window).
Trait Implementations§
Source§impl Clone for InstanceLife
impl Clone for InstanceLife
Source§impl Debug for InstanceLife
impl Debug for InstanceLife
Source§impl<'de> Deserialize<'de> for InstanceLife
impl<'de> Deserialize<'de> for InstanceLife
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for InstanceLife
Source§impl PartialEq for InstanceLife
impl PartialEq for InstanceLife
Source§impl Serialize for InstanceLife
impl Serialize for InstanceLife
impl StructuralPartialEq for InstanceLife
Auto Trait Implementations§
impl Freeze for InstanceLife
impl RefUnwindSafe for InstanceLife
impl Send for InstanceLife
impl Sync for InstanceLife
impl Unpin for InstanceLife
impl UnsafeUnpin for InstanceLife
impl UnwindSafe for InstanceLife
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
Mutably borrows from an owned value. Read more
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§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
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more