feldera_types/
checkpoint.rs

1use serde::{Deserialize, Serialize};
2use utoipa::ToSchema;
3use uuid::Uuid;
4
5/// Checkpoint status returned by the `/checkpoint_status` endpoint.
6#[derive(Clone, Debug, Default, Serialize, Deserialize, ToSchema)]
7pub struct CheckpointStatus {
8    /// Most recently successful checkpoint.
9    pub success: Option<u64>,
10
11    /// Most recently failed checkpoint, and the associated error.
12    pub failure: Option<CheckpointFailure>,
13}
14
15/// Information about a failed checkpoint.
16#[derive(Clone, Debug, Default, Serialize, Deserialize, ToSchema)]
17pub struct CheckpointFailure {
18    /// Sequence number of the failed checkpoint.
19    pub sequence_number: u64,
20
21    /// Error message associated with the failure.
22    pub error: String,
23}
24
25/// Response to a checkpoint request.
26#[derive(Clone, Debug, Default, Serialize, Deserialize, ToSchema)]
27pub struct CheckpointResponse {
28    pub checkpoint_sequence_number: u64,
29}
30
31impl CheckpointResponse {
32    pub fn new(checkpoint_sequence_number: u64) -> Self {
33        Self {
34            checkpoint_sequence_number,
35        }
36    }
37}
38
39/// Response to a sync checkpoint request.
40#[derive(Clone, Debug, Default, Serialize, Deserialize, ToSchema)]
41pub struct CheckpointSyncResponse {
42    pub checkpoint_uuid: Uuid,
43}
44
45impl CheckpointSyncResponse {
46    pub fn new(checkpoint_uuid: Uuid) -> Self {
47        Self { checkpoint_uuid }
48    }
49}
50
51/// Checkpoint status returned by the `/checkpoint/sync_status` endpoint.
52#[derive(Clone, Debug, Default, Serialize, Deserialize, ToSchema)]
53pub struct CheckpointSyncStatus {
54    /// Most recently successful checkpoint sync.
55    pub success: Option<Uuid>,
56
57    /// Most recently failed checkpoint sync, and the associated error.
58    pub failure: Option<CheckpointSyncFailure>,
59}
60
61/// Information about a failed checkpoint sync.
62#[derive(Clone, Debug, Default, Serialize, Deserialize, ToSchema)]
63pub struct CheckpointSyncFailure {
64    /// UUID of the failed checkpoint.
65    pub uuid: Uuid,
66
67    /// Error message associated with the failure.
68    pub error: String,
69}
70
71/// Holds meta-data about a checkpoint that was taken for persistent storage
72/// and recovery of a circuit's state.
73#[derive(Debug, Clone, Default, Serialize, Deserialize)]
74pub struct CheckpointMetadata {
75    /// A unique identifier for the given checkpoint.
76    ///
77    /// This is used to identify the checkpoint in the file-system hierarchy.
78    pub uuid: Uuid,
79    /// An optional name for the checkpoint.
80    pub identifier: Option<String>,
81    /// Fingerprint of the circuit at the time of the checkpoint.
82    pub fingerprint: u64,
83    /// Total size of the checkpoint files in bytes.
84    pub size: Option<u64>,
85    /// Total number of steps made.
86    pub steps: Option<u64>,
87    /// Total number of records processed.
88    pub processed_records: Option<u64>,
89}
90
91/// Format of `pspine-batches-*.dat` in storage.
92///
93/// These files exist to be a simple format for higher-level code and outside
94/// tools to parse.  The spine itself writes them for that purpose, but it does
95/// not read them.
96#[derive(Debug, Serialize, Deserialize)]
97pub struct PSpineBatches {
98    pub files: Vec<String>,
99}