feldera_types/
transaction.rs1use std::fmt::{Display, Formatter};
2
3use serde::{Deserialize, Serialize};
4use utoipa::ToSchema;
5use uuid::Uuid;
6
7pub type TransactionId = i64;
8
9#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
11pub struct StartTransactionResponse {
12 pub transaction_id: i64,
13
14 #[serde(default)]
18 pub incarnation_uuid: Option<Uuid>,
19}
20
21impl StartTransactionResponse {
22 pub fn new(transaction_id: TransactionId) -> Self {
23 Self {
24 transaction_id,
25 incarnation_uuid: None,
26 }
27 }
28}
29
30#[derive(Clone, Debug, Default, Serialize, Deserialize, ToSchema)]
32pub struct CommitProgressSummary {
33 pub completed: u64,
35
36 pub in_progress: u64,
38
39 pub remaining: u64,
41
42 pub in_progress_processed_records: u64,
44
45 pub in_progress_total_records: u64,
47}
48
49impl CommitProgressSummary {
50 pub fn new() -> Self {
51 Self::default()
52 }
53
54 pub fn merge(&mut self, other: &CommitProgressSummary) {
55 self.completed += other.completed;
56 self.in_progress += other.in_progress;
57 self.remaining += other.remaining;
58 self.in_progress_processed_records += other.in_progress_processed_records;
59 self.in_progress_total_records += other.in_progress_total_records;
60 }
61}
62
63impl Display for CommitProgressSummary {
64 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
65 write!(
66 f,
67 "completed: {} operators, evaluating: {} operators [{}/{} changes processed], remaining: {} operators",
68 self.completed,
69 self.in_progress,
70 self.in_progress_processed_records,
71 self.in_progress_total_records,
72 self.remaining
73 )
74 }
75}
76
77#[derive(
81 Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, ToSchema, bytemuck::NoUninit,
82)]
83#[repr(u8)]
84pub enum ConcurrentBootstrapPhase {
85 #[default]
87 Inactive,
88
89 ConcurrentBootstrapping,
92
93 Synchronizing,
96}
97
98impl Display for ConcurrentBootstrapPhase {
99 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
100 match self {
101 ConcurrentBootstrapPhase::Inactive => write!(f, "inactive"),
102 ConcurrentBootstrapPhase::ConcurrentBootstrapping => {
103 write!(f, "concurrent bootstrapping")
104 }
105 ConcurrentBootstrapPhase::Synchronizing => write!(f, "synchronizing"),
106 }
107 }
108}