pub struct GatewayRouter { /* private fields */ }Implementations§
Source§impl GatewayRouter
impl GatewayRouter
Sourcepub fn from_config(config: &GatewayConfig) -> Result<Self, String>
pub fn from_config(config: &GatewayConfig) -> Result<Self, String>
Build a router from gateway configuration.
Returns an error if the configuration is structurally invalid (duplicate IDs, empty backends, etc.).
Sourcepub fn route(&self, tool_name: &str) -> Option<RoutingDecision>
pub fn route(&self, tool_name: &str) -> Option<RoutingDecision>
Route a tool call to the appropriate backend.
Returns None when no healthy backend matches (fail-closed).
Sourcepub fn route_with_affinity(
&self,
tool_name: &str,
session_affinities: &HashMap<String, String>,
) -> Option<RoutingDecision>
pub fn route_with_affinity( &self, tool_name: &str, session_affinities: &HashMap<String, String>, ) -> Option<RoutingDecision>
Route with session affinity — prefer a previously used backend if healthy.
session_affinities maps tool_name → backend_id from prior routing decisions.
Sourcepub fn record_success(&self, backend_id: &str)
pub fn record_success(&self, backend_id: &str)
Record a successful response from a backend.
Transitions: Unhealthy→Degraded (after 1 success), Degraded→Healthy
(after healthy_threshold consecutive successes).
Sourcepub fn record_failure(&self, backend_id: &str)
pub fn record_failure(&self, backend_id: &str)
Record a failed response from a backend.
Marks the backend as Unhealthy after unhealthy_threshold consecutive failures.
Sourcepub fn backend_config(&self, backend_id: &str) -> Option<&BackendConfig>
pub fn backend_config(&self, backend_id: &str) -> Option<&BackendConfig>
Look up the original backend configuration by ID (Phase 29).
Used by cross-transport fallback to retrieve transport_urls.
Sourcepub fn backend_health(&self) -> Vec<(String, String, BackendHealth)>
pub fn backend_health(&self) -> Vec<(String, String, BackendHealth)>
Return a snapshot of all backend health states.
Sourcepub fn backend_count(&self) -> usize
pub fn backend_count(&self) -> usize
Number of configured backends.