rush_sync_server/proxy/
types.rs1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct ProxyConfig {
6 pub enabled: bool,
7 pub port: u16,
8 pub bind_address: String,
9 pub health_check_interval: u64, pub timeout_ms: u64,
11}
12
13impl Default for ProxyConfig {
14 fn default() -> Self {
15 Self {
16 enabled: true,
17 port: 8000,
18 bind_address: "127.0.0.1".to_string(),
19 health_check_interval: 30,
20 timeout_ms: 5000,
21 }
22 }
23}
24
25#[derive(Debug, Serialize, Deserialize)]
27pub struct ProxyConfigToml {
28 pub enabled: bool,
29 pub port: u16,
30 pub bind_address: String,
31 pub health_check_interval: u64,
32 pub timeout_ms: u64,
33}
34
35impl From<ProxyConfig> for ProxyConfigToml {
36 fn from(config: ProxyConfig) -> Self {
37 Self {
38 enabled: config.enabled,
39 port: config.port,
40 bind_address: config.bind_address,
41 health_check_interval: config.health_check_interval,
42 timeout_ms: config.timeout_ms,
43 }
44 }
45}
46
47impl From<ProxyConfigToml> for ProxyConfig {
48 fn from(config: ProxyConfigToml) -> Self {
49 Self {
50 enabled: config.enabled,
51 port: config.port,
52 bind_address: config.bind_address,
53 health_check_interval: config.health_check_interval,
54 timeout_ms: config.timeout_ms,
55 }
56 }
57}
58
59#[derive(Debug, Clone)]
60pub struct ProxyTarget {
61 pub name: String,
62 pub port: u16,
63 pub healthy: bool,
64 pub last_check: std::time::SystemTime,
65}
66
67#[derive(Debug, Clone)]
68pub struct ProxyRoute {
69 pub subdomain: String,
70 pub target_port: u16,
71 pub server_id: String,
72}
73
74pub type RouteMap = HashMap<String, ProxyRoute>;