kftray_commons/models/
config_state_model.rs1use serde::{
2 Deserialize,
3 Serialize,
4};
5
6#[derive(Clone, Deserialize, PartialEq, Serialize, Debug, Default)]
7pub struct ConfigState {
8 pub id: Option<i64>,
9 pub config_id: i64,
10 pub is_running: bool,
11 pub process_id: Option<u32>,
12 #[serde(default)]
13 pub is_retrying: bool,
14 #[serde(default)]
15 pub retry_count: Option<i32>,
16 #[serde(default)]
17 pub last_error: Option<String>,
18}
19
20impl ConfigState {
21 pub fn new(config_id: i64, is_running: bool) -> Self {
22 Self {
23 id: None,
24 config_id,
25 is_running,
26 process_id: Some(std::process::id()),
27 is_retrying: false,
28 retry_count: None,
29 last_error: None,
30 }
31 }
32
33 pub fn new_without_process(config_id: i64, is_running: bool) -> Self {
34 Self {
35 id: None,
36 config_id,
37 is_running,
38 process_id: None,
39 is_retrying: false,
40 retry_count: None,
41 last_error: None,
42 }
43 }
44}