pub struct AgentLifecycle {
pub agent_id: AgentId,
pub agent_name: Option<AgentName>,
pub version: AgentVersion,
pub version_number: VersionNumber,
pub current_state: AgentLifecycleState,
pub previous_state: Option<AgentLifecycleState>,
pub transition_timeout: TransitionTimeout,
pub drain_timeout: DrainTimeout,
pub pending_requests: PendingRequestCount,
pub failure_reason: Option<FailureReason>,
}Expand description
Agent lifecycle state with metadata
Fields§
§agent_id: AgentId§agent_name: Option<AgentName>§version: AgentVersion§version_number: VersionNumber§current_state: AgentLifecycleState§previous_state: Option<AgentLifecycleState>§transition_timeout: TransitionTimeout§drain_timeout: DrainTimeout§pending_requests: PendingRequestCount§failure_reason: Option<FailureReason>Implementations§
Source§impl AgentLifecycle
impl AgentLifecycle
Sourcepub fn new(
agent_id: AgentId,
agent_name: Option<AgentName>,
version: AgentVersion,
version_number: VersionNumber,
) -> Self
pub fn new( agent_id: AgentId, agent_name: Option<AgentName>, version: AgentVersion, version_number: VersionNumber, ) -> Self
Creates a new agent lifecycle in unloaded state
Sourcepub fn transition_to(
&mut self,
new_state: AgentLifecycleState,
failure_reason: Option<FailureReason>,
) -> Result<(), StateTransitionError>
pub fn transition_to( &mut self, new_state: AgentLifecycleState, failure_reason: Option<FailureReason>, ) -> Result<(), StateTransitionError>
Sourcepub fn start(&mut self) -> Result<(), StateTransitionError>
pub fn start(&mut self) -> Result<(), StateTransitionError>
Starts the agent (Ready -> Running)
§Errors
Returns an error if the agent cannot transition to Running state.
Sourcepub fn start_draining(&mut self) -> Result<(), StateTransitionError>
pub fn start_draining(&mut self) -> Result<(), StateTransitionError>
Begins draining the agent (Running -> Draining)
§Errors
Returns an error if the agent cannot transition to Draining state.
Sourcepub fn stop(&mut self) -> Result<(), StateTransitionError>
pub fn stop(&mut self) -> Result<(), StateTransitionError>
Stops the agent (Running/Draining/Ready -> Stopped)
§Errors
Returns an error if the agent cannot transition to Stopped state.
Sourcepub fn fail(
&mut self,
reason: FailureReason,
) -> Result<(), StateTransitionError>
pub fn fail( &mut self, reason: FailureReason, ) -> Result<(), StateTransitionError>
Marks agent as failed with reason
§Errors
Returns an error if the agent cannot transition to Failed state.
Sourcepub fn add_pending_request(&mut self) -> Result<(), StateTransitionError>
pub fn add_pending_request(&mut self) -> Result<(), StateTransitionError>
Sourcepub fn complete_request(&mut self)
pub fn complete_request(&mut self)
Decrements pending request count
Sourcepub fn is_ready_to_stop(&self) -> bool
pub fn is_ready_to_stop(&self) -> bool
Checks if agent is ready to be fully stopped (no pending requests)
Sourcepub fn get_timeout_for_state(&self) -> u64
pub fn get_timeout_for_state(&self) -> u64
Gets time-based constraints for current state
Trait Implementations§
Source§impl Clone for AgentLifecycle
impl Clone for AgentLifecycle
Source§fn clone(&self) -> AgentLifecycle
fn clone(&self) -> AgentLifecycle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AgentLifecycle
impl Debug for AgentLifecycle
Source§impl<'de> Deserialize<'de> for AgentLifecycle
impl<'de> Deserialize<'de> for AgentLifecycle
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 AgentLifecycle
Source§impl PartialEq for AgentLifecycle
impl PartialEq for AgentLifecycle
Source§impl Serialize for AgentLifecycle
impl Serialize for AgentLifecycle
impl StructuralPartialEq for AgentLifecycle
Auto Trait Implementations§
impl Freeze for AgentLifecycle
impl RefUnwindSafe for AgentLifecycle
impl Send for AgentLifecycle
impl Sync for AgentLifecycle
impl Unpin for AgentLifecycle
impl UnsafeUnpin for AgentLifecycle
impl UnwindSafe for AgentLifecycle
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<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