pjson_rs/application/queries/
mod.rs1use crate::application::dto::{PriorityDto, SessionIdDto, StreamIdDto};
4use crate::domain::{
5 aggregates::{StreamSession, stream_session::SessionHealth},
6 entities::{Frame, Stream},
7 events::DomainEvent,
8};
9use chrono::{DateTime, Utc};
10use serde::{Deserialize, Serialize};
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct GetSessionQuery {
15 pub session_id: SessionIdDto,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct GetActiveSessionsQuery {
21 pub limit: Option<usize>,
22 pub offset: Option<usize>,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct GetStreamQuery {
28 pub session_id: SessionIdDto,
29 pub stream_id: StreamIdDto,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct GetStreamsForSessionQuery {
35 pub session_id: SessionIdDto,
36 pub include_inactive: bool,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct GetSessionHealthQuery {
42 pub session_id: SessionIdDto,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct GetStreamFramesQuery {
48 pub session_id: SessionIdDto,
49 pub stream_id: StreamIdDto,
50 pub since_sequence: Option<u64>,
51 pub priority_filter: Option<PriorityDto>,
52 pub limit: Option<usize>,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct GetSessionStatsQuery {
58 pub session_id: SessionIdDto,
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63pub struct GetSystemStatsQuery {
64 pub include_historical: bool,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct GetSessionEventsQuery {
70 pub session_id: SessionIdDto,
71 pub since: Option<DateTime<Utc>>,
72 pub event_types: Option<Vec<String>>,
73 pub limit: Option<usize>,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct GetStreamEventsQuery {
79 pub stream_id: StreamIdDto,
80 pub since: Option<DateTime<Utc>>,
81 pub limit: Option<usize>,
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86pub struct SearchSessionsQuery {
87 pub filters: SessionFilters,
88 pub sort_by: Option<SessionSortField>,
89 pub sort_order: Option<SortOrder>,
90 pub limit: Option<usize>,
91 pub offset: Option<usize>,
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize, Default)]
96pub struct SessionFilters {
97 pub state: Option<String>,
98 pub created_after: Option<DateTime<Utc>>,
99 pub created_before: Option<DateTime<Utc>>,
100 pub client_info: Option<String>,
101 pub has_active_streams: Option<bool>,
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(rename_all = "snake_case")]
107pub enum SessionSortField {
108 CreatedAt,
109 UpdatedAt,
110 StreamCount,
111 TotalBytes,
112}
113
114#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(rename_all = "snake_case")]
117pub enum SortOrder {
118 Ascending,
119 Descending,
120}
121
122#[derive(Debug, Clone, Serialize, Deserialize)]
125pub struct SessionResponse {
126 pub session: StreamSession,
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize)]
131pub struct SessionsResponse {
132 pub sessions: Vec<StreamSession>,
133 pub total_count: usize,
134}
135
136#[derive(Debug, Clone, Serialize, Deserialize)]
138pub struct StreamResponse {
139 pub stream: Stream,
140}
141
142#[derive(Debug, Clone, Serialize, Deserialize)]
144pub struct StreamsResponse {
145 pub streams: Vec<Stream>,
146}
147
148#[derive(Debug, Clone, Serialize, Deserialize)]
150pub struct FramesResponse {
151 pub frames: Vec<Frame>,
152 pub total_count: usize,
153}
154
155#[derive(Debug, Clone, Serialize, Deserialize)]
157pub struct HealthResponse {
158 pub health: SessionHealth,
159}
160
161#[derive(Debug, Clone, Serialize, Deserialize)]
163pub struct EventsResponse {
164 pub events: Vec<DomainEvent>,
165 pub total_count: usize,
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize)]
170pub struct SystemStatsResponse {
171 pub total_sessions: u64,
172 pub active_sessions: u64,
173 pub total_streams: u64,
174 pub active_streams: u64,
175 pub total_frames: u64,
176 pub total_bytes: u64,
177 pub average_session_duration_seconds: f64,
178 pub frames_per_second: f64,
179 pub bytes_per_second: f64,
180 pub uptime_seconds: u64,
181}
182