pub struct ConnectionTenantBinder { /* private fields */ }Expand description
连接租户绑定器
Implementations§
Source§impl ConnectionTenantBinder
impl ConnectionTenantBinder
Sourcepub fn new(pool: Arc<Pool>, config: ConnectionLevelTenantConfig) -> Self
pub fn new(pool: Arc<Pool>, config: ConnectionLevelTenantConfig) -> Self
创建连接租户绑定器
Sourcepub fn config(&self) -> &ConnectionLevelTenantConfig
pub fn config(&self) -> &ConnectionLevelTenantConfig
获取配置
Sourcepub fn supports_set_tenant_id(&self) -> bool
pub fn supports_set_tenant_id(&self) -> bool
判断是否支持 SET app.tenant_id
Sourcepub fn build_set_tenant_sql(&self, tenant_id: &str) -> String
pub fn build_set_tenant_sql(&self, tenant_id: &str) -> String
生成 SET app.tenant_id SQL
Sourcepub fn build_clear_tenant_sql(&self) -> String
pub fn build_clear_tenant_sql(&self) -> String
生成清理租户上下文 SQL
Sourcepub fn bind_connection(&self, tenant_id: &str) -> ConnectionId
pub fn bind_connection(&self, tenant_id: &str) -> ConnectionId
绑定连接到租户
Sourcepub fn find_bound_connections(&self, tenant_id: &str) -> Vec<ConnectionId> ⓘ
pub fn find_bound_connections(&self, tenant_id: &str) -> Vec<ConnectionId> ⓘ
查找绑定到指定租户的连接
Sourcepub fn unbind_connection(&self, tenant_id: &str, conn_id: ConnectionId)
pub fn unbind_connection(&self, tenant_id: &str, conn_id: ConnectionId)
解绑连接
Sourcepub fn binding_count(&self, tenant_id: &str) -> usize
pub fn binding_count(&self, tenant_id: &str) -> usize
获取绑定数量
Sourcepub fn all_bindings(&self) -> Vec<TenantBinding>
pub fn all_bindings(&self) -> Vec<TenantBinding>
获取所有租户绑定
Sourcepub fn validate_tenant_id(&self, tenant_id: &str) -> Result<(), TenantError>
pub fn validate_tenant_id(&self, tenant_id: &str) -> Result<(), TenantError>
验证租户 ID
Sourcepub fn resolve_isolation(&self) -> ConnectionLevelIsolation
pub fn resolve_isolation(&self) -> ConnectionLevelIsolation
确定实际隔离机制(处理方言降级)
Auto Trait Implementations§
impl !Freeze for ConnectionTenantBinder
impl !RefUnwindSafe for ConnectionTenantBinder
impl !UnwindSafe for ConnectionTenantBinder
impl Send for ConnectionTenantBinder
impl Sync for ConnectionTenantBinder
impl Unpin for ConnectionTenantBinder
impl UnsafeUnpin for ConnectionTenantBinder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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