pub struct DriverRegistry { /* private fields */ }Expand description
Registry for LLM drivers
Enables dependency inversion: provider crates (everruns-anthropic, everruns-openai) register their drivers at startup. The core has no direct knowledge of implementations.
§Example
use everruns_core::{DriverRegistry, DriverId};
use everruns_anthropic::register_driver;
use everruns_openai::register_driver as register_openai;
let mut registry = DriverRegistry::new();
everruns_anthropic::register_driver(&mut registry);
everruns_openai::register_driver(&mut registry);
// Later, create a driver from config
let driver = registry.create_chat_driver(&config)?;Implementations§
Source§impl DriverRegistry
impl DriverRegistry
Sourcepub fn new() -> DriverRegistry
pub fn new() -> DriverRegistry
Create a new empty registry
Sourcepub fn register_descriptor(&mut self, descriptor: DriverDescriptor)
pub fn register_descriptor(&mut self, descriptor: DriverDescriptor)
Register a full driver descriptor.
Panics if a descriptor is already registered for the same driver id —
silent overwrites hide double-registration bugs. Use
Self::register_descriptor_or_replace to overwrite intentionally.
Sourcepub fn register_descriptor_or_replace(&mut self, descriptor: DriverDescriptor)
pub fn register_descriptor_or_replace(&mut self, descriptor: DriverDescriptor)
Register a full driver descriptor, replacing any existing one.
Sourcepub fn register<F>(&mut self, provider_type: impl Into<DriverId>, factory: F)
pub fn register<F>(&mut self, provider_type: impl Into<DriverId>, factory: F)
Register a driver factory for a provider type.
Panics if a factory is already registered for provider_type — silent
overwrites hide double-registration bugs. Use
Self::register_or_replace to overwrite intentionally.
Sourcepub fn register_or_replace<F>(
&mut self,
provider_type: impl Into<DriverId>,
factory: F,
)
pub fn register_or_replace<F>( &mut self, provider_type: impl Into<DriverId>, factory: F, )
Register a driver factory, replacing any existing one for the provider.
Use when overwriting is intentional (e.g. swapping in an LlmSim driver
for tests). Prefer Self::register otherwise so duplicates surface.
Sourcepub fn register_external<F>(&mut self, id: impl Into<Arc<str>>, factory: F)
pub fn register_external<F>(&mut self, id: impl Into<Arc<str>>, factory: F)
Register a driver factory for an embedder-defined external provider,
keyed by its canonical id. The id is normalized to lowercase (via
DriverId::external) so it matches parsed lookups regardless of
the casing stored in the database or sent on the wire.
Sourcepub fn create_chat_driver(
&self,
config: &ProviderConfig,
) -> Result<Box<dyn ChatDriver>, AgentLoopError>
pub fn create_chat_driver( &self, config: &ProviderConfig, ) -> Result<Box<dyn ChatDriver>, AgentLoopError>
Create an LLM driver based on configuration
API keys must be provided in the config for real providers. This function does NOT fall back to
environment variables. Keys should be decrypted from the database and passed here.
Exception: LlmSim and External providers do not require an API key
(external providers may authenticate via ProviderMetadata).
Returns DriverNotRegistered error if no driver is registered for the provider type.
Sourcepub fn has_driver(&self, provider_type: &DriverId) -> bool
pub fn has_driver(&self, provider_type: &DriverId) -> bool
Check if a driver is registered for a provider type
Sourcepub fn descriptor(&self, provider_type: &DriverId) -> Option<&DriverDescriptor>
pub fn descriptor(&self, provider_type: &DriverId) -> Option<&DriverDescriptor>
Get the registered descriptor for a provider type.
Sourcepub fn supports(&self, provider_type: &DriverId, service: ServiceKind) -> bool
pub fn supports(&self, provider_type: &DriverId, service: ServiceKind) -> bool
Whether the registered driver declares the given service.
Sourcepub fn providers_for(&self, service: ServiceKind) -> Vec<DriverId>
pub fn providers_for(&self, service: ServiceKind) -> Vec<DriverId>
Driver ids whose descriptors declare the given service.
Sourcepub fn registered_providers(&self) -> Vec<DriverId>
pub fn registered_providers(&self) -> Vec<DriverId>
Get the list of registered provider types
Sourcepub fn create_embeddings_driver(
&self,
config: &ProviderConfig,
) -> Result<Box<dyn EmbeddingsDriver>, EmbeddingsDriverError>
pub fn create_embeddings_driver( &self, config: &ProviderConfig, ) -> Result<Box<dyn EmbeddingsDriver>, EmbeddingsDriverError>
Create an embeddings driver based on configuration.
API keys must be provided in the config for real providers. Exception:
LlmSim and External providers do not require an API key.
Returns an error if the driver is not registered or does not implement the embeddings service.
Trait Implementations§
Source§impl Clone for DriverRegistry
impl Clone for DriverRegistry
Source§fn clone(&self) -> DriverRegistry
fn clone(&self) -> DriverRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for DriverRegistry
impl Default for DriverRegistry
Source§fn default() -> DriverRegistry
fn default() -> DriverRegistry
Auto Trait Implementations§
impl !RefUnwindSafe for DriverRegistry
impl !UnwindSafe for DriverRegistry
impl Freeze for DriverRegistry
impl Send for DriverRegistry
impl Sync for DriverRegistry
impl Unpin for DriverRegistry
impl UnsafeUnpin for DriverRegistry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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>
T in a tonic::Request