use std::sync::Arc;
use crate::control::security::catalog::{StoredCollection, StoredTenant};
use crate::control::security::tenant::TenantQuota;
use crate::control::state::SharedState;
use crate::types::TenantId;
pub fn put(stored: StoredTenant, shared: Arc<SharedState>) {
let tid = TenantId::new(stored.tenant_id);
let mut tenants = match shared.tenants.lock() {
Ok(g) => g,
Err(p) => p.into_inner(),
};
if !tenants.has_quota(tid) {
tenants.set_quota(tid, TenantQuota::default());
}
tracing::debug!(
tenant = stored.tenant_id,
name = %stored.name,
"post_apply: tenant identity replicated"
);
}
pub fn delete(tenant_id: u64, shared: Arc<SharedState>) {
let tid = TenantId::new(tenant_id);
let mut tenants = match shared.tenants.lock() {
Ok(g) => g,
Err(p) => p.into_inner(),
};
tenants.remove_quota(tid);
tracing::debug!(tenant = tenant_id, "post_apply: tenant identity removed");
}
pub fn move_cutover_sync(
tenant_id: u64,
source_db_id: u64,
target_db_id: u64,
collections: &[StoredCollection],
_shared: Arc<SharedState>,
) {
tracing::debug!(
tenant = tenant_id,
source_db = source_db_id,
target_db = target_db_id,
collection_count = collections.len(),
"post_apply: move_tenant_cutover applied"
);
}