pub struct ProviderRegistry { /* private fields */ }Expand description
Registry of available providers.
Implementations§
Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty registry.
§Examples
use codetether_agent::provider::ProviderRegistry;
let registry = ProviderRegistry::new();
assert!(registry.list().is_empty());Sourcepub fn register(&mut self, provider: Arc<dyn Provider>)
pub fn register(&mut self, provider: Arc<dyn Provider>)
Register a provider (automatically wrapped with metrics instrumentation).
§Examples
use codetether_agent::provider::ProviderRegistry;
use std::sync::Arc;
registry.register(p);Sourcepub fn get(&self, name: &str) -> Option<Arc<dyn Provider>>
pub fn get(&self, name: &str) -> Option<Arc<dyn Provider>>
Get a provider by name.
§Examples
use codetether_agent::provider::ProviderRegistry;
let registry = ProviderRegistry::new();
assert!(registry.get("openai").is_none());Sourcepub fn list(&self) -> Vec<&str>
pub fn list(&self) -> Vec<&str>
List all registered provider names.
§Examples
use codetether_agent::provider::ProviderRegistry;
let registry = ProviderRegistry::new();
assert!(registry.list().is_empty());Sourcepub fn resolve_model(
&self,
model_str: &str,
) -> Result<(Arc<dyn Provider>, String)>
pub fn resolve_model( &self, model_str: &str, ) -> Result<(Arc<dyn Provider>, String)>
Resolve a model string to a provider and model name.
Accepts:
"provider/model"(e.g."openai/gpt-4o")"model"alone (uses first available provider)
§Examples
use codetether_agent::provider::ProviderRegistry;
let registry = ProviderRegistry::new();
// No providers ⇒ error
assert!(registry.resolve_model("gpt-4o").is_err());Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub async fn from_config(config: &Config) -> Result<Self>
pub async fn from_config(config: &Config) -> Result<Self>
Initialize with default providers from the TOML config file.
Reads [providers.<name>] sections and common *_API_KEY env vars.
§Examples
use codetether_agent::provider::ProviderRegistry;
let registry = ProviderRegistry::from_config(cfg).await.unwrap();Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub async fn from_vault() -> Result<Self>
pub async fn from_vault() -> Result<Self>
Initialize providers from HashiCorp Vault with env-var fallback.
See module-level docs for the security model and fallback order.
§Examples
use codetether_agent::provider::ProviderRegistry;
let registry = ProviderRegistry::from_vault().await.unwrap();Trait Implementations§
Source§impl Debug for ProviderRegistry
impl Debug for ProviderRegistry
Auto Trait Implementations§
impl Freeze for ProviderRegistry
impl !RefUnwindSafe for ProviderRegistry
impl Send for ProviderRegistry
impl Sync for ProviderRegistry
impl Unpin for ProviderRegistry
impl UnsafeUnpin for ProviderRegistry
impl !UnwindSafe for ProviderRegistry
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§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::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more