pub struct Router { /* private fields */ }Expand description
Router selects the best backend for each request
Implementations§
Source§impl Router
impl Router
Sourcepub fn new(
registry: Arc<Registry>,
strategy: RoutingStrategy,
weights: ScoringWeights,
) -> Self
pub fn new( registry: Arc<Registry>, strategy: RoutingStrategy, weights: ScoringWeights, ) -> Self
Create a new router with the given configuration
Sourcepub fn with_aliases_and_fallbacks(
registry: Arc<Registry>,
strategy: RoutingStrategy,
weights: ScoringWeights,
aliases: HashMap<String, String>,
fallbacks: HashMap<String, Vec<String>>,
) -> Self
pub fn with_aliases_and_fallbacks( registry: Arc<Registry>, strategy: RoutingStrategy, weights: ScoringWeights, aliases: HashMap<String, String>, fallbacks: HashMap<String, Vec<String>>, ) -> Self
Create a new router with aliases and fallbacks
Sourcepub fn with_aliases_fallbacks_and_policies(
registry: Arc<Registry>,
strategy: RoutingStrategy,
weights: ScoringWeights,
aliases: HashMap<String, String>,
fallbacks: HashMap<String, Vec<String>>,
policy_matcher: PolicyMatcher,
quality_config: QualityConfig,
) -> Self
pub fn with_aliases_fallbacks_and_policies( registry: Arc<Registry>, strategy: RoutingStrategy, weights: ScoringWeights, aliases: HashMap<String, String>, fallbacks: HashMap<String, Vec<String>>, policy_matcher: PolicyMatcher, quality_config: QualityConfig, ) -> Self
Create a new router with aliases, fallbacks, and traffic policies
Sourcepub fn with_full_config(
registry: Arc<Registry>,
strategy: RoutingStrategy,
weights: ScoringWeights,
aliases: HashMap<String, String>,
fallbacks: HashMap<String, Vec<String>>,
policy_matcher: PolicyMatcher,
budget_config: BudgetConfig,
budget_state: Arc<DashMap<String, BudgetMetrics>>,
) -> Self
pub fn with_full_config( registry: Arc<Registry>, strategy: RoutingStrategy, weights: ScoringWeights, aliases: HashMap<String, String>, fallbacks: HashMap<String, Vec<String>>, policy_matcher: PolicyMatcher, budget_config: BudgetConfig, budget_state: Arc<DashMap<String, BudgetMetrics>>, ) -> Self
Create a new router with full configuration including budget
Sourcepub fn select_backend(
&self,
requirements: &RequestRequirements,
tier_enforcement_mode: Option<TierEnforcementMode>,
) -> Result<RoutingResult, RoutingError>
pub fn select_backend( &self, requirements: &RequestRequirements, tier_enforcement_mode: Option<TierEnforcementMode>, ) -> Result<RoutingResult, RoutingError>
Select the best backend for the given requirements
§Arguments
requirements- The extracted requirements from the requesttier_enforcement_mode- Optional tier enforcement mode from request headers (T032)
§Returns
Returns a RoutingResult with the selected backend and routing metadata,
or a RoutingError if no suitable backend is available.
Sourcepub fn budget_config(&self) -> &BudgetConfig
pub fn budget_config(&self) -> &BudgetConfig
Get reference to the budget configuration (F14).
Sourcepub fn budget_state(&self) -> &Arc<DashMap<String, BudgetMetrics>>
pub fn budget_state(&self) -> &Arc<DashMap<String, BudgetMetrics>>
Get reference to the budget state (F14).
Sourcepub fn quality_store(&self) -> &Arc<QualityMetricsStore>
pub fn quality_store(&self) -> &Arc<QualityMetricsStore>
Get reference to the quality metrics store.
Sourcepub fn set_queue_enabled(&mut self, enabled: bool)
pub fn set_queue_enabled(&mut self, enabled: bool)
Set whether request queuing is enabled (T026).
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