Skip to content

Commit 77b775d

Browse files
committed
refactor(nginx_enqueue.rs): streamline port parsing logic by removing redundant checks and only parsing global port if necessary
fix(nginx_enqueue.rs): ensure fallback to global proxma.port only occurs when valid, preventing processing of entries without a specified port
1 parent 7995d90 commit 77b775d

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/queue/nginx_enqueue.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,8 @@ impl NginxEnqueue {
367367
}
368368
}
369369

370-
let port = match labels.get("proxma.port").and_then(|p| p.trim().parse::<u16>().ok()) {
371-
Some(p) if p > 0 => p,
372-
_ => {
373-
println!("Invalid port for container {}, skipping processing", container_id);
374-
return;
375-
}
376-
};
370+
// Only parse global port if needed
371+
let global_port = labels.get("proxma.port").and_then(|p| p.trim().parse::<u16>().ok());
377372

378373
let ssl_staging: bool = labels.get("proxma.ssl.staging")
379374
.map(|v| v.trim().to_lowercase() == "true")
@@ -430,7 +425,7 @@ impl NginxEnqueue {
430425
}
431426
}
432427

433-
// New logic: support host:port in proxma.hosts, fallback to global proxma.port
428+
// Improved logic: support host:port in proxma.hosts, fallback to global proxma.port only if needed
434429
let entries: Vec<String> = hosts_str
435430
.split(',')
436431
.map(|s| s.trim().to_string())
@@ -449,7 +444,13 @@ impl NginxEnqueue {
449444
}
450445
}
451446
} else {
452-
(entry.clone(), port)
447+
match global_port {
448+
Some(port_val) if port_val > 0 => (entry.clone(), port_val),
449+
_ => {
450+
println!("No port specified for host '{}' and no valid global proxma.port for container {}, skipping this entry", entry, container_id);
451+
continue;
452+
}
453+
}
453454
};
454455

455456
Self::message(NginxQueueMessage {

0 commit comments

Comments
 (0)