pub struct RouterProvider { /* private fields */ }Expand description
Routes each turn to a backend that still has budget.
Implementations§
Source§impl RouterProvider
impl RouterProvider
Sourcepub fn new(
backends: Vec<Backend>,
strategy: Box<dyn RoutingStrategy>,
) -> Result<Self, RunnerError>
pub fn new( backends: Vec<Backend>, strategy: Box<dyn RoutingStrategy>, ) -> Result<Self, RunnerError>
Build a router over at least one backend.
§Errors
Returns an error when no backends are given — a router over nothing has no honest behaviour, and failing at construction beats failing on the first athlete’s turn.
Sourcepub fn with_store(self, store: Box<dyn QuotaStore>) -> Self
pub fn with_store(self, store: Box<dyn QuotaStore>) -> Self
Swap the state store — the seam a shared implementation plugs into.
The default is InMemoryQuotaStore, correct for one process. Several
processes spending one account pass RedisQuotaStore (feature
quota-redis); routers in one process can share an
Arc<InMemoryQuotaStore>. Neither changes routing or the strategy.
Sourcepub const fn with_threshold(self, percent: f32) -> Self
pub const fn with_threshold(self, percent: f32) -> Self
Set the share of a window at which the router steps aside.
Sourcepub const fn with_refresh_interval(self, interval: Duration) -> Self
pub const fn with_refresh_interval(self, interval: Duration) -> Self
Set how long a quota reading is reused before refreshing.
Sourcepub fn active_index(&self) -> usize
pub fn active_index(&self) -> usize
Index of the backend currently serving.
Sourcepub fn active_runner(&self) -> Option<Arc<dyn HeadlessTurnProvider>>
pub fn active_runner(&self) -> Option<Arc<dyn HeadlessTurnProvider>>
The concrete ACP runner behind the backend that is currently answering.
None when the live backend is not a Copilot Headless one — which is
the correct answer, not a missing feature. The platform’s dispatch reads
this to decide between the SDK tool-calling loop and the CLI text loop,
and a stale Some would run the wrong loop against the wrong provider.