Skip to content

Commit

Permalink
feat(state_machine): add access to execution history using tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
willyrgf committed Nov 26, 2023
1 parent 77c6853 commit 95158a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mfm_machine/src/state_machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::anyhow;

use crate::state::{context::ContextWrapper, StateResult, States};

use self::tracker::{HashMapTracker, Index, Tracker};
use self::tracker::{HashMapTracker, Index, Tracker, TrackerHistory};

pub mod tracker;

Expand Down Expand Up @@ -56,6 +56,10 @@ impl StateMachine {
}
}

pub fn track_history(&self) -> TrackerHistory {
self.tracker.history()
}

fn has_state(&self, state_index: usize) -> bool {
self.states.len() > state_index
}
Expand Down
5 changes: 5 additions & 0 deletions mfm_machine/tests/retry_workflow_state_machine_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ fn test_retry_workflow_state_machine() {

let result = state_machine.execute(context);

println!(
"state machine execution history: \n{:?}",
state_machine.track_history()
);

assert!(result.is_ok());
}

0 comments on commit 95158a5

Please sign in to comment.