mj_controller/controller/checkpoint/
persist.rs1use super::*;
2
3impl Controller {
4 pub(in crate::controller) fn persist_checkpoint_transition_or_restore(
5 &mut self,
6 session_id: &str,
7 previous: &SessionRecord,
8 context: &'static str,
9 ) -> Result<()> {
10 persist_session_record_transition_or_restore(
11 &mut self.state,
12 session_id,
13 previous,
14 context,
15 &crate::database::save_checkpointed_session,
16 )
17 }
18
19 pub(in crate::controller) fn persist_failed_checkpoint_state_or_restore(
20 &mut self,
21 session_id: &str,
22 previous: &SessionRecord,
23 primary: anyhow::Error,
24 ) -> anyhow::Error {
25 match self.persist_session_state(session_id) {
26 Ok(()) => primary,
27 Err(error) => self.restore_prior_session_after_persistence_failure(
28 session_id,
29 previous,
30 primary.context(format!(
31 "failed to persist the checkpoint rollback state: {error:#}"
32 )),
33 ),
34 }
35 }
36
37 pub async fn checkpoint_session(&mut self, session_id: &str) -> Result<CheckpointMetadata> {
41 self.checkpoint_session_controlled(session_id, &ProcessExecutor)
42 .await
43 }
44
45 pub async fn checkpoint_session_controlled(
46 &mut self,
47 session_id: &str,
48 executor: &(impl CommandExecutor + Sync),
49 ) -> Result<CheckpointMetadata> {
50 self.checkpoint_session_controlled_with_manager(session_id, executor, None)
51 .await
52 }
53}