kiteticker_async_manager/manager/
config.rs1use crate::models::Mode;
2use std::time::Duration;
3
4#[derive(Debug, Clone)]
6pub struct KiteManagerConfig {
7 pub max_symbols_per_connection: usize,
9
10 pub max_connections: usize,
12
13 pub connection_buffer_size: usize,
15
16 pub parser_buffer_size: usize,
18
19 pub connection_timeout: Duration,
21
22 pub health_check_interval: Duration,
24
25 pub max_reconnect_attempts: usize,
27
28 pub reconnect_delay: Duration,
30
31 pub enable_dedicated_parsers: bool,
33
34 pub default_mode: Mode,
36}
37
38impl Default for KiteManagerConfig {
39 fn default() -> Self {
40 Self {
41 max_symbols_per_connection: 3000,
42 max_connections: 3,
43 connection_buffer_size: 5000, parser_buffer_size: 10000, connection_timeout: Duration::from_secs(30),
46 health_check_interval: Duration::from_secs(10),
47 max_reconnect_attempts: 5,
48 reconnect_delay: Duration::from_secs(2),
49 enable_dedicated_parsers: true,
50 default_mode: Mode::Quote,
51 }
52 }
53}
54
55#[derive(Debug, Clone, Default)]
57pub struct ConnectionStats {
58 pub connection_id: usize,
59 pub is_connected: bool,
60 pub symbol_count: usize,
61 pub messages_received: u64,
62 pub messages_parsed: u64,
63 pub errors_count: u64,
64 pub last_message_time: Option<std::time::Instant>,
65 pub average_latency: Duration,
66 pub connection_uptime: Duration,
67}
68
69#[derive(Debug, Clone, Default)]
71pub struct ManagerStats {
72 pub total_symbols: usize,
73 pub active_connections: usize,
74 pub total_messages_received: u64,
75 pub total_messages_parsed: u64,
76 pub total_errors: u64,
77 pub uptime: Duration,
78 pub connection_stats: Vec<ConnectionStats>,
79}
80
81#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
83pub enum ChannelId {
84 Connection1 = 0,
85 Connection2 = 1,
86 Connection3 = 2,
87}
88
89impl ChannelId {
90 pub fn from_index(index: usize) -> Option<Self> {
91 match index {
92 0 => Some(Self::Connection1),
93 1 => Some(Self::Connection2),
94 2 => Some(Self::Connection3),
95 _ => None,
96 }
97 }
98
99 pub fn to_index(self) -> usize {
100 self as usize
101 }
102
103 pub fn all() -> Vec<Self> {
104 vec![Self::Connection1, Self::Connection2, Self::Connection3]
105 }
106}