use tokio::sync::OwnedSemaphorePermit;
use nodedb_types::{DatabaseId, TenantId};
#[must_use = "ConnectionPermit must be kept alive for the connection's lifetime"]
pub struct ConnectionPermit {
#[allow(dead_code)]
pub(crate) global: OwnedSemaphorePermit,
pub(crate) database: Option<OwnedSemaphorePermit>,
pub(crate) tenant: Option<OwnedSemaphorePermit>,
pub db_id: DatabaseId,
pub tenant_id: TenantId,
}
impl std::fmt::Debug for ConnectionPermit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ConnectionPermit")
.field("db_id", &self.db_id)
.field("tenant_id", &self.tenant_id)
.field("global_permit_held", &true)
.field("has_database_permit", &self.database.is_some())
.field("has_tenant_permit", &self.tenant.is_some())
.finish()
}
}