pub trait LifecycleStore: Send + Sync {
// Required methods
fn register<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn heartbeat<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn deregister<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Tracks agent liveness through register, heartbeat, and deregister.
The runtime registers an agent when it comes
online, sends periodic heartbeats while it runs,
and deregisters it on clean shutdown. Backends
use the heartbeat timestamp to expire agents that stopped reporting.
§Example
use aa_core::storage::{AgentId, LifecycleStore, Result};
use async_trait::async_trait;
/// A store that accepts all lifecycle transitions and persists nothing.
struct NullLifecycleStore;
#[async_trait]
impl LifecycleStore for NullLifecycleStore {
async fn register(&self, _agent_id: &AgentId) -> Result<()> {
Ok(())
}
async fn heartbeat(&self, _agent_id: &AgentId) -> Result<()> {
Ok(())
}
async fn deregister(&self, _agent_id: &AgentId) -> Result<()> {
Ok(())
}
}Required Methods§
Sourcefn register<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn register<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Record that agent_id is now online.
Overwrites any stale registration for the same agent.
Sourcefn heartbeat<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn heartbeat<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Refresh the liveness timestamp for agent_id.
Returns StorageError::NotFound when the
agent is not currently registered.
Sourcefn deregister<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn deregister<'life0, 'life1, 'async_trait>(
&'life0 self,
agent_id: &'life1 AgentId,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Record that agent_id has gone offline.
Idempotent: deregistering an agent that is not registered succeeds.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".