1use crate::event::EventSequence;
2use chrono::{DateTime, Utc};
3use jamjet_core::workflow::ExecutionId;
4use serde::{Deserialize, Serialize};
5use uuid::Uuid;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct Snapshot {
12 pub id: Uuid,
13 pub execution_id: ExecutionId,
14 pub at_sequence: EventSequence,
16 pub state: serde_json::Value,
18 pub created_at: DateTime<Utc>,
19}
20
21impl Snapshot {
22 pub fn new(
23 execution_id: ExecutionId,
24 at_sequence: EventSequence,
25 state: serde_json::Value,
26 ) -> Self {
27 Self {
28 id: Uuid::new_v4(),
29 execution_id,
30 at_sequence,
31 state,
32 created_at: Utc::now(),
33 }
34 }
35}
36
37pub const DEFAULT_SNAPSHOT_INTERVAL: i64 = 50;