pub struct ProviderManager { /* private fields */ }Expand description
Central registry of LLM providers with health, stats, and rate-limit tracking.
Implementations§
Source§impl ProviderManager
impl ProviderManager
Sourcepub fn set_cost_per_token(&mut self, provider_id: &str, cost: f64)
pub fn set_cost_per_token(&mut self, provider_id: &str, cost: f64)
Set the estimated cost per token (USD) for a provider.
Used by best_provider_for_budget.
Sourcepub fn update_health(&mut self, health: ProviderHealth)
pub fn update_health(&mut self, health: ProviderHealth)
Replace the stored health snapshot for a provider.
Sourcepub fn select_provider(
&mut self,
selection: &ProviderSelection,
now: u64,
) -> Option<&Provider>
pub fn select_provider( &mut self, selection: &ProviderSelection, now: u64, ) -> Option<&Provider>
Choose a provider according to selection.
Rate-limited or disabled providers are skipped. Returns None if no
eligible provider exists.
Sourcepub fn failover_chain(&self) -> Vec<&Provider>
pub fn failover_chain(&self) -> Vec<&Provider>
Return healthy, enabled providers sorted by ascending priority (lowest = best).
Sourcepub fn record_request(
&mut self,
provider_id: &str,
tokens: u64,
latency_ms: u64,
success: bool,
)
pub fn record_request( &mut self, provider_id: &str, tokens: u64, latency_ms: u64, success: bool, )
Record the outcome of a request to a provider.
Sourcepub fn provider_stats(&self, provider_id: &str) -> Option<ProviderStats>
pub fn provider_stats(&self, provider_id: &str) -> Option<ProviderStats>
Return the cumulative stats for a provider, if any requests have been recorded.
Sourcepub fn best_provider_for_budget(
&self,
cost_per_token_limit: f64,
) -> Option<&Provider>
pub fn best_provider_for_budget( &self, cost_per_token_limit: f64, ) -> Option<&Provider>
Return the cheapest healthy provider whose cost-per-token is ≤ cost_per_token_limit.
Trait Implementations§
Source§impl Debug for ProviderManager
impl Debug for ProviderManager
Source§impl Default for ProviderManager
impl Default for ProviderManager
Source§fn default() -> ProviderManager
fn default() -> ProviderManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ProviderManager
impl RefUnwindSafe for ProviderManager
impl Send for ProviderManager
impl Sync for ProviderManager
impl Unpin for ProviderManager
impl UnsafeUnpin for ProviderManager
impl UnwindSafe for ProviderManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request