pub struct Router { /* private fields */ }Expand description
The router manages provider selection and fallback.
Implementations§
Source§impl Router
impl Router
Sourcepub fn new(routes: Vec<ProviderRoute>, strategy: RoutingStrategy) -> Self
pub fn new(routes: Vec<ProviderRoute>, strategy: RoutingStrategy) -> Self
Create a new router with the given routes and strategy.
Sourcepub fn set_health_map(&mut self, map: HealthMap)
pub fn set_health_map(&mut self, map: HealthMap)
Set the health map for background health check filtering.
Sourcepub fn select(&self, model: &str) -> Option<&ProviderRoute>
pub fn select(&self, model: &str) -> Option<&ProviderRoute>
Select the best provider for a given model.
Sourcepub fn report_latency(
&self,
provider: ProviderType,
base_url: &str,
latency_ms: u64,
)
pub fn report_latency( &self, provider: ProviderType, base_url: &str, latency_ms: u64, )
Report observed latency for a provider, updating an exponential moving average.
Sourcepub fn reload(&mut self, routes: Vec<ProviderRoute>, strategy: RoutingStrategy)
pub fn reload(&mut self, routes: Vec<ProviderRoute>, strategy: RoutingStrategy)
Replace routes and strategy atomically.
Sourcepub fn routes(&self) -> &[ProviderRoute]
pub fn routes(&self) -> &[ProviderRoute]
All configured routes.
Auto Trait Implementations§
impl !Freeze for Router
impl !RefUnwindSafe for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin for Router
impl !UnwindSafe for Router
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more