pub struct TenantDatabaseConfig {
pub database_prefix: Option<String>,
pub database_suffix: Option<String>,
pub auto_create: bool,
pub template_database: Option<String>,
pub pool_size_per_tenant: usize,
pub max_tenant_connections: usize,
}Expand description
Configuration for database-based tenant isolation.
Fields§
§database_prefix: Option<String>Prefix for tenant database names.
database_suffix: Option<String>Suffix for tenant database names.
auto_create: boolWhether to create databases automatically.
template_database: Option<String>Template database for new tenant databases.
pool_size_per_tenant: usizeConnection pool size per tenant.
max_tenant_connections: usizeMaximum number of tenant connections to keep.
Implementations§
Source§impl DatabaseConfig
impl DatabaseConfig
Sourcepub fn with_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_prefix(self, prefix: impl Into<String>) -> Self
Set the database prefix.
Sourcepub fn with_suffix(self, suffix: impl Into<String>) -> Self
pub fn with_suffix(self, suffix: impl Into<String>) -> Self
Set the database suffix.
Sourcepub fn with_auto_create(self) -> Self
pub fn with_auto_create(self) -> Self
Enable auto-creation of databases.
Sourcepub fn with_template(self, template: impl Into<String>) -> Self
pub fn with_template(self, template: impl Into<String>) -> Self
Set the template database.
Sourcepub fn with_pool_size(self, size: usize) -> Self
pub fn with_pool_size(self, size: usize) -> Self
Set the pool size per tenant.
Sourcepub fn with_max_connections(self, max: usize) -> Self
pub fn with_max_connections(self, max: usize) -> Self
Set the maximum tenant connections.
Sourcepub fn database_name(&self, tenant_id: &str) -> String
pub fn database_name(&self, tenant_id: &str) -> String
Generate the database name for a tenant.
Trait Implementations§
Source§impl Clone for DatabaseConfig
impl Clone for DatabaseConfig
Source§fn clone(&self) -> DatabaseConfig
fn clone(&self) -> DatabaseConfig
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DatabaseConfig
impl Debug for DatabaseConfig
Source§impl Default for DatabaseConfig
impl Default for DatabaseConfig
Source§fn default() -> DatabaseConfig
fn default() -> DatabaseConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DatabaseConfig
impl RefUnwindSafe for DatabaseConfig
impl Send for DatabaseConfig
impl Sync for DatabaseConfig
impl Unpin for DatabaseConfig
impl UnwindSafe for DatabaseConfig
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)