Check if creating a new collection would exceed the ceiling.
(&self, tenant_id: u64, current_count: u64)
| 62 | |
| 63 | /// Check if creating a new collection would exceed the ceiling. |
| 64 | pub fn check_collection_limit(&self, tenant_id: u64, current_count: u64) -> crate::Result<()> { |
| 65 | let ceilings = self.ceilings.read().unwrap_or_else(|p| p.into_inner()); |
| 66 | if let Some(c) = ceilings.get(&tenant_id) |
| 67 | && c.max_collections > 0 |
| 68 | && current_count >= c.max_collections |
| 69 | { |
| 70 | return Err(crate::Error::RejectedAuthz { |
| 71 | tenant_id: crate::types::TenantId::new(tenant_id), |
| 72 | resource: format!("ceiling exceeded: max_collections = {}", c.max_collections), |
| 73 | }); |
| 74 | } |
| 75 | Ok(()) |
| 76 | } |
| 77 | |
| 78 | /// Check if adding storage would exceed the ceiling. |
| 79 | pub fn check_storage_limit( |