nautilus_persistence/writer/
run.rs1use nautilus_common::enums::Environment;
13
14use crate::common::storage::StorageBackend;
15
16#[derive(Clone)]
17pub struct FeatherSessionSource {
18 pub storage: StorageBackend,
19 pub environment: Environment,
20 pub instance_id: String,
21}
22
23impl FeatherSessionSource {
24 #[must_use]
25 pub fn new(
26 storage: StorageBackend,
27 environment: Environment,
28 instance_id: impl Into<String>,
29 ) -> Self {
30 Self {
31 storage,
32 environment,
33 instance_id: instance_id.into(),
34 }
35 }
36}
37
38#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
39pub enum RunStatus {
40 InProgress,
41 Completed,
42 Promoted,
43 Failed,
44}
45
46impl RunStatus {
47 #[must_use]
48 pub const fn as_str(self) -> &'static str {
49 match self {
50 Self::InProgress => "in_progress",
51 Self::Completed => "completed",
52 Self::Promoted => "promoted",
53 Self::Failed => "failed",
54 }
55 }
56
57 #[must_use]
58 pub fn from_storage_str(value: &str) -> Self {
59 match value {
60 "in_progress" => Self::InProgress,
61 "completed" => Self::Completed,
62 "promoted" => Self::Promoted,
63 "failed" => Self::Failed,
64 _ => {
65 log::warn!(
66 "Unknown catalog run status '{value}'; treating the run as failed for recovery"
67 );
68 Self::Failed
69 }
70 }
71 }
72}