pub struct DatabaseServiceProvider { /* private fields */ }Expand description
Database service provider for connection pool
Implementations§
Source§impl DatabaseServiceProvider
impl DatabaseServiceProvider
pub fn new(database_url: String) -> Self
pub fn with_registry(self, registry: Arc<DatabaseBackendRegistry>) -> Self
pub fn with_config(self, config: DatabasePoolConfig) -> Self
pub fn with_max_connections(self, max_connections: u32) -> Self
pub fn with_min_connections(self, min_connections: u32) -> Self
pub fn with_acquire_timeout(self, timeout_seconds: u64) -> Self
pub fn with_idle_timeout(self, timeout_seconds: Option<u64>) -> Self
pub fn with_max_lifetime(self, lifetime_seconds: Option<u64>) -> Self
pub fn with_test_before_acquire(self, enabled: bool) -> Self
pub fn with_service_name(self, service_name: String) -> Self
Sourcepub async fn create_pool(
&self,
) -> Result<Arc<dyn DatabasePoolTrait>, ModelError>
pub async fn create_pool( &self, ) -> Result<Arc<dyn DatabasePoolTrait>, ModelError>
Create a database pool using this provider’s configuration
Sourcepub async fn create_managed_pool(&self) -> Result<ManagedPool, ModelError>
pub async fn create_managed_pool(&self) -> Result<ManagedPool, ModelError>
Create a managed database pool with statistics and health monitoring
Sourcepub fn database_url(&self) -> &str
pub fn database_url(&self) -> &str
Get the database URL (for diagnostic purposes)
Sourcepub fn service_name(&self) -> &str
pub fn service_name(&self) -> &str
Get the service name for this provider
Sourcepub fn config(&self) -> &DatabasePoolConfig
pub fn config(&self) -> &DatabasePoolConfig
Get the pool configuration
Trait Implementations§
Source§impl ServiceProvider for DatabaseServiceProvider
impl ServiceProvider for DatabaseServiceProvider
Source§fn register(
&self,
builder: ContainerBuilder,
) -> Result<ContainerBuilder, ProviderError>
fn register( &self, builder: ContainerBuilder, ) -> Result<ContainerBuilder, ProviderError>
Register services in the container builder
This is called during the registration phase
Source§fn boot(&self, _container: &Container) -> Result<(), ProviderError>
fn boot(&self, _container: &Container) -> Result<(), ProviderError>
Boot the provider after all services are registered
This is called during the boot phase with access to the built container
Source§fn dependencies(&self) -> Vec<&'static str>
fn dependencies(&self) -> Vec<&'static str>
Provider dependencies (other providers that must be registered first)
Source§fn defer_boot(&self) -> bool
fn defer_boot(&self) -> bool
Defer boot phase (useful for providers that need other providers to be booted first)
Source§fn description(&self) -> Option<&'static str>
fn description(&self) -> Option<&'static str>
Provider description
Source§fn is_optional(&self) -> bool
fn is_optional(&self) -> bool
Check if this provider is optional
Auto Trait Implementations§
impl Freeze for DatabaseServiceProvider
impl !RefUnwindSafe for DatabaseServiceProvider
impl Send for DatabaseServiceProvider
impl Sync for DatabaseServiceProvider
impl Unpin for DatabaseServiceProvider
impl !UnwindSafe for DatabaseServiceProvider
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 more