1use serde::{Deserialize, Serialize};
4use std::net::SocketAddr;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct DashboardConfig {
9 pub bind_address: SocketAddr,
11
12 pub enable_cors: bool,
14
15 pub storage_path: String,
17
18 pub max_page_size: usize,
20
21 pub default_page_size: usize,
23
24 pub cache_size_mb: usize,
26
27 pub auto_refresh_interval_secs: u64,
29
30 pub otlp_grpc_port: u16,
32
33 pub otlp_http_port: u16,
35}
36
37impl Default for DashboardConfig {
38 fn default() -> Self {
39 Self {
40 bind_address: "127.0.0.1:3000".parse().unwrap(),
41 enable_cors: false,
42 storage_path: "otelite.db".to_string(),
43 max_page_size: 1000,
44 default_page_size: 100,
45 cache_size_mb: 10,
46 auto_refresh_interval_secs: 1,
47 otlp_grpc_port: 4317,
48 otlp_http_port: 4318,
49 }
50 }
51}
52
53impl DashboardConfig {
54 pub fn with_bind_address(mut self, addr: SocketAddr) -> Self {
56 self.bind_address = addr;
57 self
58 }
59
60 pub fn with_cors(mut self, enable: bool) -> Self {
62 self.enable_cors = enable;
63 self
64 }
65
66 pub fn with_storage_path(mut self, path: impl Into<String>) -> Self {
68 self.storage_path = path.into();
69 self
70 }
71
72 pub fn with_otlp_ports(mut self, grpc_port: u16, http_port: u16) -> Self {
74 self.otlp_grpc_port = grpc_port;
75 self.otlp_http_port = http_port;
76 self
77 }
78}