removed separate port field from config for backends
This commit is contained in:
32
config.yaml
32
config.yaml
@@ -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:
|
backends:
|
||||||
- id: "srv-1"
|
- id: "srv-1"
|
||||||
ip: "127.0.0.1"
|
ip: "10.0.1.1:8081"
|
||||||
port: 8081
|
|
||||||
|
|
||||||
- id: "srv-2"
|
- id: "srv-2"
|
||||||
ip: "127.0.0.1"
|
ip: "10.0.1.2:8082"
|
||||||
port: 8082
|
- id: "srv-3"
|
||||||
|
ip: "10.0.1.3:8083"
|
||||||
|
- id: "srv-4"
|
||||||
|
ip: "10.0.1.4:8084"
|
||||||
|
|
||||||
clusters:
|
clusters:
|
||||||
main-api:
|
main-api:
|
||||||
- "srv-1"
|
- "srv-1"
|
||||||
- "srv-2"
|
- "srv-2"
|
||||||
priority-api:
|
priority-api:
|
||||||
- "srv-1"
|
- "srv-3"
|
||||||
|
- "srv-4"
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
- clients:
|
- clients:
|
||||||
- "0.0.0.0/0:8888"
|
- "0.0.0.0/0:80"
|
||||||
targets:
|
targets:
|
||||||
- "main-api"
|
- "main-api"
|
||||||
strategy:
|
strategy:
|
||||||
type: "RoundRobin"
|
type: "RoundRobin"
|
||||||
|
|
||||||
- clients:
|
- clients:
|
||||||
- "0.0.0.0/0:6767"
|
- "10.0.0.0/24:80"
|
||||||
- "0.0.0.0/0:6969"
|
- "10.0.0.0/24:8080"
|
||||||
targets: # no issues with duplicate servers or clusters
|
- "10.0.1.0/24:8080"
|
||||||
- "priority-api"
|
targets:
|
||||||
- "priority-api"
|
- "main-api"
|
||||||
- "priority-api"
|
- "priority-api"
|
||||||
strategy:
|
strategy:
|
||||||
type: "Adaptive"
|
type: "Adaptive"
|
||||||
coefficients: [ 1.5, 1.0, 0.5, 0.1 ]
|
coefficients: [ 1.5, 1.0, 0.5, 0.1 ]
|
||||||
alpha: 0.75
|
alpha: 0.75
|
||||||
|
|||||||
@@ -36,11 +36,9 @@ pub fn build_lb(
|
|||||||
let mut backends: HashMap<String, Arc<Backend>> = HashMap::new();
|
let mut backends: HashMap<String, Arc<Backend>> = HashMap::new();
|
||||||
|
|
||||||
for backend_cfg in &config.backends {
|
for backend_cfg in &config.backends {
|
||||||
let ip: IpAddr = backend_cfg
|
let addr: SocketAddr = backend_cfg.ip.parse()
|
||||||
.ip
|
|
||||||
.parse()
|
|
||||||
.map_err(|_| format!("bad ip: {}", backend_cfg.ip))?;
|
.map_err(|_| format!("bad ip: {}", backend_cfg.ip))?;
|
||||||
let addr = SocketAddr::new(ip, backend_cfg.port);
|
let ip = addr.ip();
|
||||||
|
|
||||||
let health = healths
|
let health = healths
|
||||||
.entry(ip)
|
.entry(ip)
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ pub struct AppConfig {
|
|||||||
pub struct BackendConfig {
|
pub struct BackendConfig {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub ip: String,
|
pub ip: String,
|
||||||
pub port: u16,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
|
|||||||
Reference in New Issue
Block a user