Class TenantQuota
- Namespace
- JD.AI.Core.MultiTenancy
- Assembly
- JD.AI.Core.dll
Per-tenant resource quotas and rate limits. Tracks usage per tenant within a configurable time window.
public sealed class TenantQuota
- Inheritance
-
TenantQuota
- Inherited Members
Constructors
TenantQuota(TenantQuotaConfig?)
public TenantQuota(TenantQuotaConfig? config = null)
Parameters
configTenantQuotaConfig
Methods
AcquireSession(string)
Increments the concurrent session count for the given tenant. Call ReleaseSession(string) when the session ends.
public void AcquireSession(string tenantId)
Parameters
tenantIdstring
GetUsage(string)
Gets current usage stats for a tenant.
public TenantUsageStats GetUsage(string tenantId)
Parameters
tenantIdstring
Returns
IsOverRequestQuota(string)
Checks if the tenant has exceeded their request quota.
public bool IsOverRequestQuota(string tenantId)
Parameters
tenantIdstring
Returns
IsOverSessionQuota(string)
Checks if the tenant has exceeded their concurrent session limit.
public bool IsOverSessionQuota(string tenantId)
Parameters
tenantIdstring
Returns
IsOverTokenQuota(string)
Checks if the tenant has exceeded their daily token budget.
public bool IsOverTokenQuota(string tenantId)
Parameters
tenantIdstring
Returns
RecordRequest(string)
Records a request for the given tenant.
public void RecordRequest(string tenantId)
Parameters
tenantIdstring
RecordTokens(string, long)
Records token consumption for the given tenant.
public void RecordTokens(string tenantId, long tokens)
Parameters
ReleaseSession(string)
Decrements the concurrent session count for the given tenant.
public void ReleaseSession(string tenantId)
Parameters
tenantIdstring