pub struct CheckpointManager { /* private fields */ }Expand description
Manages atomic checkpoint persistence for durable sessions.
Each checkpoint atomically stores an event and the updated run-state so that a crash cannot leave an event emitted but un-checkpointed (or vice versa).
§Example
use adk_managed::checkpoint::{CheckpointManager, RunState};
use adk_managed::types::{SessionEvent, SessionStatus, ContentBlock};
let mut mgr = CheckpointManager::new("session_001".to_string());
let event = SessionEvent::StatusRunning { seq: 0 };
let state = RunState { seq: 1, pending_tool_ids: vec![], status: SessionStatus::Running };
mgr.checkpoint(event, state.clone());
assert_eq!(mgr.events().len(), 1);
assert_eq!(mgr.run_state(), &state);Implementations§
Source§impl CheckpointManager
impl CheckpointManager
Sourcepub fn new(session_id: String) -> Self
pub fn new(session_id: String) -> Self
Create a new checkpoint manager for the given session.
Initializes with an empty event log and the initial run state (seq=0, no pending tools, queued status).
Sourcepub fn checkpoint(&mut self, event: SessionEvent, run_state: RunState)
pub fn checkpoint(&mut self, event: SessionEvent, run_state: RunState)
Atomically persist an event and updated run-state.
Both the event and the new state are stored together in one operation, guaranteeing that replay will see a consistent view after any crash.
Sourcepub fn load_checkpoint(&self) -> (Vec<SessionEvent>, RunState)
pub fn load_checkpoint(&self) -> (Vec<SessionEvent>, RunState)
Load the last checkpoint for resume.
Returns all stored events and the current run state, providing everything needed to reconstruct a session after a restart.
Sourcepub fn events(&self) -> &[SessionEvent]
pub fn events(&self) -> &[SessionEvent]
Get all events stored in the checkpoint log.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Get the session ID this manager is checkpointing for.