pub struct ProviderRouter { /* private fields */ }Expand description
Routes agent invocations to different providers based on model/config matching.
Evaluates matchers in registration order; first match wins. If no matcher matches, the fallback provider handles the request.
§Examples
use std::sync::Arc;
use ironflow_core::providers::router::{ProviderRouter, ProviderMatcher};
use ironflow_core::providers::claude::ClaudeCodeProvider;
use ironflow_core::provider::{AgentConfig, AgentProvider};
let claude = Arc::new(ClaudeCodeProvider::new());
let router = ProviderRouter::new(claude.clone());
// Uses the fallback (claude) since no routes match "sonnet"
let config = AgentConfig::new("hello");
let output = router.invoke(&config).await?;Implementations§
Source§impl ProviderRouter
impl ProviderRouter
Sourcepub fn new(fallback: Arc<dyn AgentProvider>) -> Self
pub fn new(fallback: Arc<dyn AgentProvider>) -> Self
Create a router with a fallback provider for unmatched models.
Sourcepub fn route(
self,
matcher: ProviderMatcher,
provider: Arc<dyn AgentProvider>,
) -> Self
pub fn route( self, matcher: ProviderMatcher, provider: Arc<dyn AgentProvider>, ) -> Self
Add a routing rule. Routes are evaluated in order; first match wins.
Trait Implementations§
Source§impl AgentProvider for ProviderRouter
impl AgentProvider for ProviderRouter
Source§fn invoke<'a>(&'a self, config: &'a AgentConfig) -> InvokeFuture<'a>
fn invoke<'a>(&'a self, config: &'a AgentConfig) -> InvokeFuture<'a>
Execute a single agent invocation with the given configuration. Read more
Source§fn invoke_with_logs<'a>(
&'a self,
config: &'a AgentConfig,
log_sink: Arc<dyn LogSink>,
) -> InvokeFuture<'a>
fn invoke_with_logs<'a>( &'a self, config: &'a AgentConfig, log_sink: Arc<dyn LogSink>, ) -> InvokeFuture<'a>
Execute an agent invocation with real-time log streaming. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for ProviderRouter
impl !UnwindSafe for ProviderRouter
impl Freeze for ProviderRouter
impl Send for ProviderRouter
impl Sync for ProviderRouter
impl Unpin for ProviderRouter
impl UnsafeUnpin for ProviderRouter
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