Skip to main content

feldera_types/
checkpoint.rs

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