1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! [`LifecycleStore`] — agent register / heartbeat / deregister bookkeeping.
use ;
use async_trait;
/// Tracks agent liveness through register, heartbeat, and deregister.
///
/// The runtime [`register`](LifecycleStore::register)s an agent when it comes
/// online, sends periodic [`heartbeat`](LifecycleStore::heartbeat)s while it runs,
/// and [`deregister`](LifecycleStore::deregister)s 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(())
/// }
/// }
/// ```