pub struct DatabaseRegistry { /* private fields */ }Expand description
Registry managing shared database instances.
When a connection requests a database by name, the registry either returns an existing shared instance or creates a new one. This ensures all connections to the same database name share the same data.
Implementations§
Source§impl DatabaseRegistry
impl DatabaseRegistry
Sourcepub async fn get_or_create(&self, name: &str) -> SharedDatabase
pub async fn get_or_create(&self, name: &str) -> SharedDatabase
Get or create a shared database instance for the given name.
If a database with the given name already exists, returns a clone of its shared handle. Otherwise, creates a new database and returns it.
Sourcepub async fn get(&self, name: &str) -> Option<SharedDatabase>
pub async fn get(&self, name: &str) -> Option<SharedDatabase>
Get a shared database instance if it exists.
Returns None if no database with the given name exists.
Sourcepub async fn list_databases(&self) -> Vec<String>
pub async fn list_databases(&self) -> Vec<String>
List all database names in the registry.
Sourcepub async fn database_count(&self) -> usize
pub async fn database_count(&self) -> usize
Get the number of databases in the registry.
Sourcepub async fn register_database(&self, name: &str, db: Database)
pub async fn register_database(&self, name: &str, db: Database)
Register a pre-built database instance.
This is useful for benchmarks where the database is pre-loaded with data before starting the server.
Trait Implementations§
Source§impl Clone for DatabaseRegistry
impl Clone for DatabaseRegistry
Source§fn clone(&self) -> DatabaseRegistry
fn clone(&self) -> DatabaseRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for DatabaseRegistry
impl !UnwindSafe for DatabaseRegistry
impl Freeze for DatabaseRegistry
impl Send for DatabaseRegistry
impl Sync for DatabaseRegistry
impl Unpin for DatabaseRegistry
impl UnsafeUnpin for DatabaseRegistry
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
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>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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