[router] fix grpc connection mode detection (#9999)
This commit is contained in:
@@ -986,7 +986,7 @@ pub fn start_health_checker(
|
|||||||
|
|
||||||
// Periodically reset load counters to prevent drift
|
// Periodically reset load counters to prevent drift
|
||||||
// Only do this when we believe all workers should be idle
|
// Only do this when we believe all workers should be idle
|
||||||
if check_count % LOAD_RESET_INTERVAL == 0 {
|
if check_count.is_multiple_of(LOAD_RESET_INTERVAL) {
|
||||||
let max_load = workers_to_check.iter().map(|w| w.load()).max().unwrap_or(0);
|
let max_load = workers_to_check.iter().map(|w| w.load()).max().unwrap_or(0);
|
||||||
// Only reset if load appears to be very low (likely drift)
|
// Only reset if load appears to be very low (likely drift)
|
||||||
if max_load <= 2 {
|
if max_load <= 2 {
|
||||||
|
|||||||
@@ -101,25 +101,13 @@ struct Router {
|
|||||||
impl Router {
|
impl Router {
|
||||||
/// Determine connection mode from worker URLs
|
/// Determine connection mode from worker URLs
|
||||||
fn determine_connection_mode(worker_urls: &[String]) -> config::ConnectionMode {
|
fn determine_connection_mode(worker_urls: &[String]) -> config::ConnectionMode {
|
||||||
// Check if any URL is a gRPC endpoint (starts with grpc:// or has port that commonly indicates gRPC)
|
// Only consider it gRPC if explicitly specified with grpc:// or grpcs:// scheme
|
||||||
for url in worker_urls {
|
for url in worker_urls {
|
||||||
if url.starts_with("grpc://") || url.starts_with("grpcs://") {
|
if url.starts_with("grpc://") || url.starts_with("grpcs://") {
|
||||||
return config::ConnectionMode::Grpc;
|
return config::ConnectionMode::Grpc;
|
||||||
}
|
}
|
||||||
// Also check for common gRPC ports if the scheme isn't specified
|
|
||||||
if let Ok(parsed_url) = url::Url::parse(url) {
|
|
||||||
if let Some(port) = parsed_url.port() {
|
|
||||||
// Common gRPC ports
|
|
||||||
if port == 50051 || port == 9090 || ((50000..=50100).contains(&port)) {
|
|
||||||
return config::ConnectionMode::Grpc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if url.contains(":50051") || url.contains(":9090") || url.contains(":5000") {
|
|
||||||
// Fallback check for URLs that might not parse correctly
|
|
||||||
return config::ConnectionMode::Grpc;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Default to HTTP
|
// Default to HTTP for all other cases (including http://, https://, or no scheme)
|
||||||
config::ConnectionMode::Http
|
config::ConnectionMode::Http
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -286,25 +286,13 @@ struct CliArgs {
|
|||||||
impl CliArgs {
|
impl CliArgs {
|
||||||
/// Determine connection mode from worker URLs
|
/// Determine connection mode from worker URLs
|
||||||
fn determine_connection_mode(worker_urls: &[String]) -> ConnectionMode {
|
fn determine_connection_mode(worker_urls: &[String]) -> ConnectionMode {
|
||||||
// Check if any URL is a gRPC endpoint (starts with grpc:// or has port that commonly indicates gRPC)
|
// Only consider it gRPC if explicitly specified with grpc:// or grpcs:// scheme
|
||||||
for url in worker_urls {
|
for url in worker_urls {
|
||||||
if url.starts_with("grpc://") || url.starts_with("grpcs://") {
|
if url.starts_with("grpc://") || url.starts_with("grpcs://") {
|
||||||
return ConnectionMode::Grpc;
|
return ConnectionMode::Grpc;
|
||||||
}
|
}
|
||||||
// Also check for common gRPC ports if the scheme isn't specified
|
|
||||||
if let Ok(parsed_url) = url::Url::parse(url) {
|
|
||||||
if let Some(port) = parsed_url.port() {
|
|
||||||
// Common gRPC ports
|
|
||||||
if port == 50051 || port == 9090 || ((50000..=50100).contains(&port)) {
|
|
||||||
return ConnectionMode::Grpc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if url.contains(":50051") || url.contains(":9090") || url.contains(":5000") {
|
|
||||||
// Fallback check for URLs that might not parse correctly
|
|
||||||
return ConnectionMode::Grpc;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Default to HTTP
|
// Default to HTTP for all other cases (including http://, https://, or no scheme)
|
||||||
ConnectionMode::Http
|
ConnectionMode::Http
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user