Skip to main content

stasis/dashboard/
dto.rs

1use chrono::{DateTime, Utc};
2
3#[derive(Clone, Debug)]
4pub struct UiPanel<T> {
5    pub title: String,
6    pub subtitle: Option<String>,
7    pub refreshed_at: DateTime<Utc>,
8    pub data: T,
9}
10
11#[derive(Clone, Debug)]
12pub struct UiListPanel<T> {
13    pub items: Vec<T>,
14    pub total: Option<u64>,
15    pub cursor: Option<String>,
16}
17
18#[derive(Clone, Debug)]
19pub struct UiTimelinePanel<T> {
20    pub entity_id: String,
21    pub events: Vec<TimelineEvent<T>>,
22}
23
24#[derive(Clone, Debug)]
25pub struct TimelineEvent<T> {
26    pub timestamp: DateTime<Utc>,
27    pub kind: String,
28    pub payload: T,
29}
30
31#[derive(Clone, Debug)]
32pub struct UiMetricPanel {
33    pub counters: Vec<CounterCard>,
34    pub timeseries: Vec<TimeSeries>,
35}
36
37#[derive(Clone, Debug)]
38pub struct CounterCard {
39    pub key: String,
40    pub label: String,
41    pub value: u64,
42    pub trend_hint: Option<String>,
43}
44
45#[derive(Clone, Debug)]
46pub struct TimeSeries {
47    pub key: String,
48    pub label: String,
49    pub points: Vec<TimePoint>,
50}
51
52#[derive(Clone, Debug)]
53pub struct TimePoint {
54    pub at: DateTime<Utc>,
55    pub value: f64,
56}
57
58#[derive(Clone, Debug)]
59pub struct SystemKpiDto {
60    pub succeeded_jobs: usize,
61    pub failed_jobs: usize,
62    pub enqueued_jobs: usize,
63    pub running_jobs: usize,
64    pub pending_outbox: usize,
65    pub failed_outbox: usize,
66    pub healthy_nodes: usize,
67    pub degraded_nodes: usize,
68    pub offline_nodes: usize,
69    pub endpoint_failure_rate: String,
70}
71
72#[derive(Clone, Debug)]
73pub struct DashboardDto {
74    pub kpis: SystemKpiDto,
75    pub job_stream: UiListPanel<JobRowDto>,
76    pub outbox_stream: UiListPanel<OutboxEventRowDto>,
77    pub cluster_map: ClusterMapDto,
78    pub inspector: InspectorView,
79}
80
81#[derive(Clone, Debug)]
82pub struct JobRowDto {
83    pub id: String,
84    pub job_type: String,
85    pub queue: String,
86    pub status: String,
87    pub priority: i32,
88    pub attempts: u32,
89    pub lease_owner: Option<String>,
90    pub trace_id: String,
91    pub updated_at: DateTime<Utc>,
92}
93
94#[derive(Clone, Debug)]
95pub struct OutboxEventRowDto {
96    pub event_id: String,
97    pub event_type: String,
98    pub correlation_id: String,
99    pub delivery_state: String,
100    pub retry_attempts: u32,
101    pub occurred_at: DateTime<Utc>,
102}
103
104#[derive(Clone, Debug)]
105pub struct EndpointRowDto {
106    pub endpoint_id: String,
107    pub endpoint_name: String,
108    pub protocol: String,
109    pub target: String,
110    pub enabled: bool,
111    pub success_count: u64,
112    pub failure_count: u64,
113    pub failure_rate: f64,
114    pub failure_rate_percent: f64,
115    pub unhealthy: bool,
116    pub last_error: Option<String>,
117}
118
119#[derive(Clone, Debug)]
120pub struct RecurringDefinitionRowDto {
121    pub id: String,
122    pub queue: String,
123    pub job_type: String,
124    pub cron_expr: String,
125    pub timezone: String,
126    pub enabled: bool,
127    pub next_run_at: DateTime<Utc>,
128    pub last_run_at: Option<DateTime<Utc>>,
129}
130
131#[derive(Clone, Debug)]
132pub struct ClusterMapDto {
133    pub nodes: Vec<ClusterNodeCardDto>,
134}
135
136#[derive(Clone, Debug)]
137pub struct ClusterNodeCardDto {
138    pub node_id: String,
139    pub role: String,
140    pub region: String,
141    pub health: String,
142    pub queue_ownership_count: usize,
143    pub capability_count: usize,
144    pub lease_expires_at: DateTime<Utc>,
145}
146
147#[derive(Clone, Debug)]
148pub struct JobInspectorDto {
149    pub id: String,
150    pub status: String,
151    pub queue: String,
152    pub trace_id: String,
153    pub correlation_id: String,
154    pub causation_id: String,
155    pub last_error: Option<String>,
156}
157
158#[derive(Clone, Debug)]
159pub struct AttemptInspectorDto {
160    pub attempt_id: String,
161    pub job_id: String,
162    pub outcome: String,
163    pub worker_id: String,
164    pub duration_ms: Option<u64>,
165    pub guardrail_code: Option<String>,
166    pub policy_reason: Option<String>,
167}
168
169#[derive(Clone, Debug)]
170pub struct EndpointInspectorDto {
171    pub endpoint_id: String,
172    pub protocol: String,
173    pub target: String,
174    pub enabled: bool,
175    pub success_count: u64,
176    pub failure_count: u64,
177    pub last_error: Option<String>,
178}
179
180#[derive(Clone, Debug)]
181pub struct NodeInspectorDto {
182    pub node_id: String,
183    pub region: String,
184    pub role: String,
185    pub health: String,
186    pub queue_ownership: Vec<String>,
187    pub capability_tags: Vec<String>,
188}
189
190#[derive(Clone, Debug)]
191pub struct EventInspectorDto {
192    pub event_id: String,
193    pub event_type: String,
194    pub job_id: String,
195    pub correlation_id: String,
196    pub trace_id: String,
197    pub status: String,
198}
199
200#[derive(Clone, Debug)]
201pub enum InspectorView {
202    Job(JobInspectorDto),
203    Attempt(AttemptInspectorDto),
204    Endpoint(EndpointInspectorDto),
205    Node(NodeInspectorDto),
206    Event(EventInspectorDto),
207    None,
208}