removed separate port field from config for backends

This commit is contained in:
psun256
2025-12-10 20:40:27 -05:00
parent b9eca8a56e
commit 74e329b17c
3 changed files with 19 additions and 20 deletions

View File

@@ -1,39 +1,41 @@
healthcheck_addr: "127.0.0.1:9000"
healthcheck_addr: "0.0.0.0:9000"
iperf_addr: "0.0.0.0:5200"
iperf_addr: "0.0.0.0:5201"
backends:
- id: "srv-1"
ip: "127.0.0.1"
port: 8081
ip: "10.0.1.1:8081"
- id: "srv-2"
ip: "127.0.0.1"
port: 8082
ip: "10.0.1.2:8082"
- id: "srv-3"
ip: "10.0.1.3:8083"
- id: "srv-4"
ip: "10.0.1.4:8084"
clusters:
main-api:
- "srv-1"
- "srv-2"
priority-api:
- "srv-1"
- "srv-3"
- "srv-4"
rules:
- clients:
- "0.0.0.0/0:8888"
- "0.0.0.0/0:80"
targets:
- "main-api"
strategy:
type: "RoundRobin"
- clients:
- "0.0.0.0/0:6767"
- "0.0.0.0/0:6969"
targets: # no issues with duplicate servers or clusters
- "priority-api"
- "priority-api"
- "10.0.0.0/24:80"
- "10.0.0.0/24:8080"
- "10.0.1.0/24:8080"
targets:
- "main-api"
- "priority-api"
strategy:
type: "Adaptive"
coefficients: [ 1.5, 1.0, 0.5, 0.1 ]
alpha: 0.75
alpha: 0.75

View File

@@ -36,11 +36,9 @@ pub fn build_lb(
let mut backends: HashMap<String, Arc<Backend>> = HashMap::new();
for backend_cfg in &config.backends {
let ip: IpAddr = backend_cfg
.ip
.parse()
let addr: SocketAddr = backend_cfg.ip.parse()
.map_err(|_| format!("bad ip: {}", backend_cfg.ip))?;
let addr = SocketAddr::new(ip, backend_cfg.port);
let ip = addr.ip();
let health = healths
.entry(ip)

View File

@@ -44,7 +44,6 @@ pub struct AppConfig {
pub struct BackendConfig {
pub id: String,
pub ip: String,
pub port: u16,
}
#[derive(Debug, Deserialize)]