pub struct ConfigRoutingTable { /* private fields */ }Expand description
Configuration-driven routing table.
Routes incoming model names to concrete provider targets using three strategies:
- Direct routing:
"provider:model_id"routes directly to the named provider. - Model lookup: Names are looked up in the
modelsmap, which supports prioritised failover and round-robin load balancing. - Default provider fallback: When no explicit
modelssection is configured and the default provider (bitrouter) exists, bare model names are forwarded to that provider.
Implementations§
Source§impl ConfigRoutingTable
impl ConfigRoutingTable
pub fn new( providers: HashMap<String, ProviderConfig>, models: HashMap<String, ModelConfig>, ) -> Self
Sourcepub fn with_routing(
providers: HashMap<String, ProviderConfig>,
models: HashMap<String, ModelConfig>,
routing: &HashMap<String, RoutingRuleConfig>,
) -> Self
pub fn with_routing( providers: HashMap<String, ProviderConfig>, models: HashMap<String, ModelConfig>, routing: &HashMap<String, RoutingRuleConfig>, ) -> Self
Creates a routing table with content-based auto-routing rules.
Sourcepub fn providers(&self) -> &HashMap<String, ProviderConfig>
pub fn providers(&self) -> &HashMap<String, ProviderConfig>
Returns a reference to the resolved provider configurations.
Sourcepub fn model_info(&self, provider_name: &str, model_id: &str) -> ModelInfo
pub fn model_info(&self, provider_name: &str, model_id: &str) -> ModelInfo
Returns the model metadata for a given provider and model ID.
Falls back to ModelInfo::default() for unknown providers or
unconfigured models.
Sourcepub fn model_pricing(&self, provider_name: &str, model_id: &str) -> ModelPricing
pub fn model_pricing(&self, provider_name: &str, model_id: &str) -> ModelPricing
Returns the token pricing for a given provider and model ID.
Convenience wrapper around model_info that
returns only the pricing component. Falls back to
ModelPricing::default() (all zeros) for unknown providers or
unconfigured models.
Sourcepub fn resolve(&self, incoming: &str) -> Result<ResolvedTarget>
pub fn resolve(&self, incoming: &str) -> Result<ResolvedTarget>
Resolves an incoming model name to a full target with any per-endpoint overrides.
Trait Implementations§
Source§impl ModelRegistry for ConfigRoutingTable
impl ModelRegistry for ConfigRoutingTable
Source§fn list_models(&self) -> Vec<ModelEntry>
fn list_models(&self) -> Vec<ModelEntry>
Lists all models available across all configured providers.
Source§impl RoutingTable for ConfigRoutingTable
impl RoutingTable for ConfigRoutingTable
Source§async fn route(
&self,
incoming_name: &str,
context: &RouteContext,
) -> Result<RoutingTarget>
async fn route( &self, incoming_name: &str, context: &RouteContext, ) -> Result<RoutingTarget>
Routes an incoming name to a routing target. Read more
Source§fn list_routes(&self) -> Vec<RouteEntry>
fn list_routes(&self) -> Vec<RouteEntry>
Lists all configured routes.
Auto Trait Implementations§
impl Freeze for ConfigRoutingTable
impl RefUnwindSafe for ConfigRoutingTable
impl Send for ConfigRoutingTable
impl Sync for ConfigRoutingTable
impl Unpin for ConfigRoutingTable
impl UnsafeUnpin for ConfigRoutingTable
impl UnwindSafe for ConfigRoutingTable
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more