pub struct TenantRegistry { /* private fields */ }Expand description
Registry of active tenants with per-tenant quotas and per-engagement cost accounting.
Implementations§
Source§impl TenantRegistry
impl TenantRegistry
Sourcepub fn with_audit_sink(sink: Arc<dyn AuditSink>) -> Self
pub fn with_audit_sink(sink: Arc<dyn AuditSink>) -> Self
Create a registry that forwards audit events (cross-tenant attempts, quota violations) to the given sink.
Sourcepub fn set_audit_sink(&mut self, sink: Arc<dyn AuditSink>)
pub fn set_audit_sink(&mut self, sink: Arc<dyn AuditSink>)
Replace the audit sink on an existing registry.
Sourcepub fn register(&self, tenant_id: TenantId, quota: TenantQuota) -> Result<()>
pub fn register(&self, tenant_id: TenantId, quota: TenantQuota) -> Result<()>
Register a new tenant with the given quota.
Sourcepub fn deregister(&self, tenant_id: TenantId) -> bool
pub fn deregister(&self, tenant_id: TenantId) -> bool
Deregister a tenant, dropping all quota and cost state.
Sourcepub fn is_registered(&self, tenant_id: TenantId) -> bool
pub fn is_registered(&self, tenant_id: TenantId) -> bool
Returns true if the tenant is registered.
Sourcepub fn get(&self, tenant_id: TenantId) -> Option<Arc<TenantInfo>>
pub fn get(&self, tenant_id: TenantId) -> Option<Arc<TenantInfo>>
Get a snapshot of tenant info (fast Arc clone, no lock held).
Sourcepub fn tenant_count(&self) -> usize
pub fn tenant_count(&self) -> usize
Number of registered tenants.
Sourcepub fn tenant_ids(&self) -> Vec<TenantId> ⓘ
pub fn tenant_ids(&self) -> Vec<TenantId> ⓘ
All registered tenant IDs.
Sourcepub fn check_quota(
&self,
tenant_id: TenantId,
audit_tag: AuditTag,
) -> Result<()>
pub fn check_quota( &self, tenant_id: TenantId, audit_tag: AuditTag, ) -> Result<()>
Check whether a send from tenant_id with audit_tag is within quota.
Sourcepub fn record_message(&self, tenant_id: TenantId)
pub fn record_message(&self, tenant_id: TenantId)
Record a message send for rate-limit accounting.
Sourcepub fn track_usage(
&self,
tenant_id: TenantId,
audit_tag: AuditTag,
gpu_seconds: Duration,
)
pub fn track_usage( &self, tenant_id: TenantId, audit_tag: AuditTag, gpu_seconds: Duration, )
Record billable GPU-seconds against a (tenant_id, audit_tag) pair.
Sourcepub fn get_engagement_cost(&self, audit_tag: AuditTag) -> Duration
pub fn get_engagement_cost(&self, audit_tag: AuditTag) -> Duration
Get total billable duration for a specific engagement across all registered tenants that have reported cost for it.
Sourcepub fn get_engagement_cost_for(
&self,
tenant_id: TenantId,
audit_tag: AuditTag,
) -> Duration
pub fn get_engagement_cost_for( &self, tenant_id: TenantId, audit_tag: AuditTag, ) -> Duration
Get billable duration for a specific (tenant_id, engagement_id) pair.
Sourcepub fn is_cross_tenant(&self, from: TenantId, to: TenantId) -> bool
pub fn is_cross_tenant(&self, from: TenantId, to: TenantId) -> bool
Returns true if a send would be cross-tenant.
Sourcepub fn audit_cross_tenant(
&self,
from_tenant: TenantId,
to_tenant: TenantId,
source_kernel: &str,
destination_kernel: &str,
audit_tag: AuditTag,
)
pub fn audit_cross_tenant( &self, from_tenant: TenantId, to_tenant: TenantId, source_kernel: &str, destination_kernel: &str, audit_tag: AuditTag, )
Emit an audit event for a cross-tenant K2K send attempt (rejected).
Sourcepub fn acquire_kernel_slot(&self, tenant_id: TenantId) -> Result<()>
pub fn acquire_kernel_slot(&self, tenant_id: TenantId) -> Result<()>
Increment the registered-kernel counter for this tenant, enforcing
TenantQuota::max_concurrent_kernels.
Sourcepub fn release_kernel_slot(&self, tenant_id: TenantId)
pub fn release_kernel_slot(&self, tenant_id: TenantId)
Release a kernel slot (call on kernel termination / deregister).