pub struct TenantManager { /* private fields */ }Expand description
Central tenant manager
Coordinates all multi-tenancy functionality including identification, isolation, connection pooling, and metrics.
Implementations§
Source§impl TenantManager
impl TenantManager
Sourcepub fn with_config(config: MultiTenancyConfig) -> Self
pub fn with_config(config: MultiTenancyConfig) -> Self
Create a tenant manager with custom configuration
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if multi-tenancy is enabled
Sourcepub fn register_tenant(&self, config: TenantConfig)
pub fn register_tenant(&self, config: TenantConfig)
Register a tenant
Sourcepub fn unregister_tenant(&self, tenant: &TenantId) -> Option<TenantConfig>
pub fn unregister_tenant(&self, tenant: &TenantId) -> Option<TenantConfig>
Unregister a tenant
Sourcepub fn get_tenant(&self, tenant: &TenantId) -> Option<TenantConfig>
pub fn get_tenant(&self, tenant: &TenantId) -> Option<TenantConfig>
Get tenant configuration
Sourcepub fn has_tenant(&self, tenant: &TenantId) -> bool
pub fn has_tenant(&self, tenant: &TenantId) -> bool
Check if tenant exists
Sourcepub fn tenant_ids(&self) -> Vec<TenantId>
pub fn tenant_ids(&self) -> Vec<TenantId>
Get all tenant IDs
Sourcepub fn tenant_count(&self) -> usize
pub fn tenant_count(&self) -> usize
Get tenant count
Sourcepub fn identify_tenant(&self, request: &RequestContext) -> Option<TenantId>
pub fn identify_tenant(&self, request: &RequestContext) -> Option<TenantId>
Identify tenant from request context
Sourcepub fn get_routing(&self, tenant: &TenantId) -> Option<RoutingDecision>
pub fn get_routing(&self, tenant: &TenantId) -> Option<RoutingDecision>
Get routing decision for a tenant
Sourcepub fn transform_query(&self, query: &str, tenant: &TenantId) -> TransformResult
pub fn transform_query(&self, query: &str, tenant: &TenantId) -> TransformResult
Transform a query for tenant isolation
Sourcepub fn validate_query(&self, query: &str, tenant: &TenantId) -> QueryValidation
pub fn validate_query(&self, query: &str, tenant: &TenantId) -> QueryValidation
Validate a query for a tenant
Sourcepub fn get_pool(&self, tenant: &TenantId) -> Option<Arc<TenantPool>>
pub fn get_pool(&self, tenant: &TenantId) -> Option<Arc<TenantPool>>
Get connection pool for a tenant
Sourcepub fn record_query(
&self,
tenant: &TenantId,
duration: Duration,
rows: u64,
bytes_read: u64,
bytes_written: u64,
success: bool,
)
pub fn record_query( &self, tenant: &TenantId, duration: Duration, rows: u64, bytes_read: u64, bytes_written: u64, success: bool, )
Record a query execution
Sourcepub fn tenant_metrics(&self, tenant: &TenantId) -> Option<TenantMetricsSnapshot>
pub fn tenant_metrics(&self, tenant: &TenantId) -> Option<TenantMetricsSnapshot>
Get metrics for a tenant
Sourcepub fn aggregate_metrics(&self) -> AggregateMetricsSnapshot
pub fn aggregate_metrics(&self) -> AggregateMetricsSnapshot
Get aggregate metrics
Sourcepub fn top_tenants_by_queries(&self, limit: usize) -> Vec<TenantMetricsSnapshot>
pub fn top_tenants_by_queries(&self, limit: usize) -> Vec<TenantMetricsSnapshot>
Get top tenants by queries
Sourcepub fn tenant_cost(&self, tenant: &TenantId) -> Option<f64>
pub fn tenant_cost(&self, tenant: &TenantId) -> Option<f64>
Get cost for a tenant
Sourcepub fn cost_report(&self) -> TenantCostReport
pub fn cost_report(&self) -> TenantCostReport
Get cost report
Sourcepub fn pool_stats(&self) -> Vec<TenantPoolStats>
pub fn pool_stats(&self) -> Vec<TenantPoolStats>
Get pool statistics for all tenants
Sourcepub fn aggregate_pool_stats(&self) -> AggregatePoolStats
pub fn aggregate_pool_stats(&self) -> AggregatePoolStats
Get aggregate pool statistics
Sourcepub fn provisioner(&self) -> &TenantProvisioner
pub fn provisioner(&self) -> &TenantProvisioner
Get the tenant provisioner
Sourcepub fn query_transformer(&self) -> &TenantQueryTransformer
pub fn query_transformer(&self) -> &TenantQueryTransformer
Get the query transformer
Sourcepub fn metrics(&self) -> &TenantMetrics
pub fn metrics(&self) -> &TenantMetrics
Get the metrics collector
Sourcepub fn is_admin_request(&self, request: &RequestContext) -> bool
pub fn is_admin_request(&self, request: &RequestContext) -> bool
Check if request is from admin user
Sourcepub fn update_tenant(&self, tenant: &TenantId, config: TenantConfig) -> bool
pub fn update_tenant(&self, tenant: &TenantId, config: TenantConfig) -> bool
Update tenant configuration
Sourcepub fn enable_tenant(&self, tenant: &TenantId) -> bool
pub fn enable_tenant(&self, tenant: &TenantId) -> bool
Enable a tenant
Sourcepub fn disable_tenant(&self, tenant: &TenantId) -> bool
pub fn disable_tenant(&self, tenant: &TenantId) -> bool
Disable a tenant
Sourcepub fn is_tenant_enabled(&self, tenant: &TenantId) -> bool
pub fn is_tenant_enabled(&self, tenant: &TenantId) -> bool
Check if tenant is enabled
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TenantManager
impl !RefUnwindSafe for TenantManager
impl Send for TenantManager
impl Sync for TenantManager
impl Unpin for TenantManager
impl UnsafeUnpin for TenantManager
impl !UnwindSafe for TenantManager
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> 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 more