pub struct BackendRouter { /* private fields */ }Expand description
Routes tool names to backends. Built once at startup from config.
Implementations§
Source§impl BackendRouter
impl BackendRouter
Sourcepub fn new(
configs: &[BackendConfig],
fallback_url: Option<&str>,
fallback_auth: Option<HeaderValue>,
) -> Result<Self, String>
pub fn new( configs: &[BackendConfig], fallback_url: Option<&str>, fallback_auth: Option<HeaderValue>, ) -> Result<Self, String>
Build from config. Resolves static credentials at construction time
so the hot path does no I/O. fallback_auth is the credential for
fallback_url (the tool_upstream_bearer_* setting); it rides on
the implicit default backend so every call to that upstream carries it.
Sourcepub fn resolve(&self, tool: &str) -> Option<&ResolvedBackend>
pub fn resolve(&self, tool: &str) -> Option<&ResolvedBackend>
Resolve a tool name to its backend. Returns None when no backend
is configured for this tool and no default exists.
Sourcepub fn iter(&self) -> impl Iterator<Item = &ResolvedBackend>
pub fn iter(&self) -> impl Iterator<Item = &ResolvedBackend>
Iterator over all configured backends.
Sourcepub fn get(&self, name: &str) -> Option<&ResolvedBackend>
pub fn get(&self, name: &str) -> Option<&ResolvedBackend>
The backend with this name, if configured.
Sourcepub fn with_fallback_transport(self, transport: BackendTransport) -> Self
pub fn with_fallback_transport(self, transport: BackendTransport) -> Self
Set the wire protocol of the implicit backend built from
tool_upstream_url (tool_upstream_transport). Explicit
[[backends]] entries keep their own setting.
Auto Trait Implementations§
impl Freeze for BackendRouter
impl RefUnwindSafe for BackendRouter
impl Send for BackendRouter
impl Sync for BackendRouter
impl Unpin for BackendRouter
impl UnsafeUnpin for BackendRouter
impl UnwindSafe for BackendRouter
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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> 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