systemprompt_models/artifacts/dashboard/section_data/
status.rs1use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
10pub struct StatusSectionData {
11 pub services: Vec<ServiceStatus>,
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub database: Option<DatabaseStatus>,
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub recent_errors: Option<ErrorCounts>,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
19pub struct ServiceStatus {
20 pub name: String,
21 pub status: String,
22 #[serde(skip_serializing_if = "Option::is_none")]
23 pub uptime: Option<String>,
24}
25
26#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
27pub struct DatabaseStatus {
28 pub size_mb: f64,
29 pub status: String,
30}
31
32#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema)]
33pub struct ErrorCounts {
34 pub critical: i32,
35 pub error: i32,
36 pub warn: i32,
37}
38
39impl StatusSectionData {
40 pub const fn new(services: Vec<ServiceStatus>) -> Self {
41 Self {
42 services,
43 database: None,
44 recent_errors: None,
45 }
46 }
47
48 pub fn with_database(mut self, status: DatabaseStatus) -> Self {
49 self.database = Some(status);
50 self
51 }
52
53 pub const fn with_error_counts(mut self, counts: ErrorCounts) -> Self {
54 self.recent_errors = Some(counts);
55 self
56 }
57}
58
59impl ServiceStatus {
60 pub fn new(name: impl Into<String>, status: impl Into<String>) -> Self {
61 Self {
62 name: name.into(),
63 status: status.into(),
64 uptime: None,
65 }
66 }
67
68 pub fn with_uptime(mut self, uptime: impl Into<String>) -> Self {
69 self.uptime = Some(uptime.into());
70 self
71 }
72}
73
74impl DatabaseStatus {
75 pub fn new(size_mb: f64, status: impl Into<String>) -> Self {
76 Self {
77 size_mb,
78 status: status.into(),
79 }
80 }
81}
82
83impl ErrorCounts {
84 pub const fn new(critical: i32, error: i32, warn: i32) -> Self {
85 Self {
86 critical,
87 error,
88 warn,
89 }
90 }
91}