Struct TenantRegistry
pub struct TenantRegistry {
tenants: RwLock<RawRwLock, HashMap<String, Arc<TenantEntry>>>,
default_quota: ResourceQuota,
window_duration: Duration,
}Expand description
Registry for managing tenants.
Fields§
§tenants: RwLock<RawRwLock, HashMap<String, Arc<TenantEntry>>>§default_quota: ResourceQuota§window_duration: DurationImplementations§
§impl TenantRegistry
impl TenantRegistry
pub fn new() -> TenantRegistry
pub fn new() -> TenantRegistry
Create a new tenant registry.
pub fn with_default_quota(self, quota: ResourceQuota) -> TenantRegistry
pub fn with_default_quota(self, quota: ResourceQuota) -> TenantRegistry
Set default quota for new tenants.
pub fn with_window_duration(self, duration: Duration) -> TenantRegistry
pub fn with_window_duration(self, duration: Duration) -> TenantRegistry
Set rate limit window duration.
pub fn with_tenant(
self,
tenant_id: impl Into<String>,
quota: ResourceQuota,
) -> TenantRegistry
pub fn with_tenant( self, tenant_id: impl Into<String>, quota: ResourceQuota, ) -> TenantRegistry
Register a tenant with quota.
pub fn register_tenant(
&self,
tenant_id: impl Into<String>,
quota: ResourceQuota,
) -> Result<(), TenantError>
pub fn register_tenant( &self, tenant_id: impl Into<String>, quota: ResourceQuota, ) -> Result<(), TenantError>
Register a new tenant.
pub fn get_quota(&self, tenant_id: &str) -> Option<ResourceQuota>
pub fn get_quota(&self, tenant_id: &str) -> Option<ResourceQuota>
Get a tenant’s quota.
pub fn get_usage(&self, tenant_id: &str) -> Option<ResourceUsage>
pub fn get_usage(&self, tenant_id: &str) -> Option<ResourceUsage>
Get a tenant’s current usage.
pub fn tenant_exists(&self, tenant_id: &str) -> bool
pub fn tenant_exists(&self, tenant_id: &str) -> bool
Check if tenant exists.
pub fn is_tenant_active(&self, tenant_id: &str) -> bool
pub fn is_tenant_active(&self, tenant_id: &str) -> bool
Check if tenant is active.
pub fn suspend_tenant(&self, tenant_id: &str) -> Result<(), TenantError>
pub fn suspend_tenant(&self, tenant_id: &str) -> Result<(), TenantError>
Suspend a tenant. Suspended tenants cannot allocate resources or send messages.
pub fn resume_tenant(&self, tenant_id: &str) -> Result<(), TenantError>
pub fn resume_tenant(&self, tenant_id: &str) -> Result<(), TenantError>
Resume a previously suspended tenant.
pub fn try_allocate_kernel(&self, tenant_id: &str) -> Result<(), TenantError>
pub fn try_allocate_kernel(&self, tenant_id: &str) -> Result<(), TenantError>
Check and increment kernel count.
pub fn release_kernel(&self, tenant_id: &str)
pub fn release_kernel(&self, tenant_id: &str)
Release a kernel allocation.
pub fn try_allocate_gpu_memory(
&self,
tenant_id: &str,
mb: u64,
) -> Result<(), TenantError>
pub fn try_allocate_gpu_memory( &self, tenant_id: &str, mb: u64, ) -> Result<(), TenantError>
Check and increment GPU memory.
pub fn release_gpu_memory(&self, tenant_id: &str, mb: u64)
pub fn release_gpu_memory(&self, tenant_id: &str, mb: u64)
Release GPU memory allocation.
pub fn record_message(&self, tenant_id: &str) -> Result<(), TenantError>
pub fn record_message(&self, tenant_id: &str) -> Result<(), TenantError>
Record a message sent.
pub fn get_utilization(&self, tenant_id: &str) -> Option<QuotaUtilization>
pub fn get_utilization(&self, tenant_id: &str) -> Option<QuotaUtilization>
Get utilization for a tenant.
pub fn tenant_ids(&self) -> Vec<String>
pub fn tenant_ids(&self) -> Vec<String>
Get all tenant IDs.
pub fn tenant_count(&self) -> usize
pub fn tenant_count(&self) -> usize
Get tenant count.
Trait Implementations§
§impl Default for TenantRegistry
impl Default for TenantRegistry
§fn default() -> TenantRegistry
fn default() -> TenantRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for TenantRegistry
impl !RefUnwindSafe for TenantRegistry
impl Send for TenantRegistry
impl Sync for TenantRegistry
impl Unpin for TenantRegistry
impl !UnwindSafe for TenantRegistry
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.