pub struct TenantConfig {
pub strategy: IsolationStrategy,
pub require_tenant: bool,
pub default_tenant: Option<String>,
pub allow_bypass: bool,
pub resolver: Option<Arc<dyn TenantResolver>>,
pub enforce_on_writes: bool,
pub log_tenant_context: bool,
}Expand description
Configuration for multi-tenant support.
Fields§
§strategy: IsolationStrategyThe isolation strategy.
require_tenant: boolWhether tenant context is required for all queries.
default_tenant: Option<String>Default tenant ID for queries without context.
allow_bypass: boolAllow superuser to bypass tenant filtering.
resolver: Option<Arc<dyn TenantResolver>>Tenant resolver for dynamic tenant lookup.
enforce_on_writes: boolWhether to enforce tenant on write operations.
log_tenant_context: boolWhether to log tenant context with queries.
Implementations§
Source§impl TenantConfig
impl TenantConfig
Sourcepub fn schema_based() -> Self
pub fn schema_based() -> Self
Create a schema-based isolation config.
Sourcepub fn database_based() -> Self
pub fn database_based() -> Self
Create a database-based isolation config.
Sourcepub fn builder() -> TenantConfigBuilder
pub fn builder() -> TenantConfigBuilder
Create a builder for advanced configuration.
Sourcepub fn with_default_tenant(self, tenant: impl Into<String>) -> Self
pub fn with_default_tenant(self, tenant: impl Into<String>) -> Self
Set the default tenant.
Sourcepub fn without_bypass(self) -> Self
pub fn without_bypass(self) -> Self
Disable superuser bypass.
Sourcepub fn with_resolver<R: TenantResolver + 'static>(self, resolver: R) -> Self
pub fn with_resolver<R: TenantResolver + 'static>(self, resolver: R) -> Self
Set the tenant resolver.
Sourcepub fn with_logging(self) -> Self
pub fn with_logging(self) -> Self
Enable tenant context logging.
Sourcepub fn row_level_config(&self) -> Option<&RowLevelConfig>
pub fn row_level_config(&self) -> Option<&RowLevelConfig>
Get the row-level config.
Sourcepub fn schema_config(&self) -> Option<&SchemaConfig>
pub fn schema_config(&self) -> Option<&SchemaConfig>
Get the schema config.
Sourcepub fn database_config(&self) -> Option<&DatabaseConfig>
pub fn database_config(&self) -> Option<&DatabaseConfig>
Get the database config.
Trait Implementations§
Source§impl Clone for TenantConfig
impl Clone for TenantConfig
Source§fn clone(&self) -> TenantConfig
fn clone(&self) -> TenantConfig
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 moreAuto Trait Implementations§
impl Freeze for TenantConfig
impl !RefUnwindSafe for TenantConfig
impl Send for TenantConfig
impl Sync for TenantConfig
impl Unpin for TenantConfig
impl !UnwindSafe for TenantConfig
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)