[router] Add IGW (Inference Gateway) Feature Flag (#9371)

Co-authored-by: Yineng Zhang <me@zhyncs.com>
This commit is contained in:
Keyang Ru
2025-08-20 17:38:57 -07:00
committed by GitHub
parent 88fbc31b50
commit 3828db4309
10 changed files with 74 additions and 8 deletions

View File

@@ -51,6 +51,9 @@ pub struct RouterConfig {
pub disable_circuit_breaker: bool,
/// Health check configuration
pub health_check: HealthCheckConfig,
/// Enable Inference Gateway mode (false = proxy mode, true = IGW mode)
#[serde(default)]
pub enable_igw: bool,
}
/// Routing mode configuration
@@ -323,6 +326,7 @@ impl Default for RouterConfig {
disable_retries: false,
disable_circuit_breaker: false,
health_check: HealthCheckConfig::default(),
enable_igw: false,
}
}
}
@@ -377,6 +381,11 @@ impl RouterConfig {
}
cfg
}
/// Check if running in IGW (Inference Gateway) mode
pub fn is_igw_mode(&self) -> bool {
self.enable_igw
}
}
#[cfg(test)]
@@ -456,6 +465,7 @@ mod tests {
disable_retries: false,
disable_circuit_breaker: false,
health_check: HealthCheckConfig::default(),
enable_igw: false,
};
let json = serde_json::to_string(&config).unwrap();
@@ -888,6 +898,7 @@ mod tests {
disable_retries: false,
disable_circuit_breaker: false,
health_check: HealthCheckConfig::default(),
enable_igw: false,
};
assert!(config.mode.is_pd_mode());
@@ -944,6 +955,7 @@ mod tests {
disable_retries: false,
disable_circuit_breaker: false,
health_check: HealthCheckConfig::default(),
enable_igw: false,
};
assert!(!config.mode.is_pd_mode());
@@ -996,6 +1008,7 @@ mod tests {
disable_retries: false,
disable_circuit_breaker: false,
health_check: HealthCheckConfig::default(),
enable_igw: false,
};
assert!(config.has_service_discovery());

View File

@@ -344,6 +344,11 @@ impl ConfigValidator {
/// Validate compatibility between different configuration sections
fn validate_compatibility(config: &RouterConfig) -> ConfigResult<()> {
// IGW mode is independent - skip other compatibility checks when enabled
if config.enable_igw {
return Ok(());
}
// All policies are now supported for both router types thanks to the unified trait design
// No mode/policy restrictions needed anymore