Table of Contents

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

config TenantQuotaConfig

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

tenantId string

GetUsage(string)

Gets current usage stats for a tenant.

public TenantUsageStats GetUsage(string tenantId)

Parameters

tenantId string

Returns

TenantUsageStats

IsOverRequestQuota(string)

Checks if the tenant has exceeded their request quota.

public bool IsOverRequestQuota(string tenantId)

Parameters

tenantId string

Returns

bool

IsOverSessionQuota(string)

Checks if the tenant has exceeded their concurrent session limit.

public bool IsOverSessionQuota(string tenantId)

Parameters

tenantId string

Returns

bool

IsOverTokenQuota(string)

Checks if the tenant has exceeded their daily token budget.

public bool IsOverTokenQuota(string tenantId)

Parameters

tenantId string

Returns

bool

RecordRequest(string)

Records a request for the given tenant.

public void RecordRequest(string tenantId)

Parameters

tenantId string

RecordTokens(string, long)

Records token consumption for the given tenant.

public void RecordTokens(string tenantId, long tokens)

Parameters

tenantId string

The tenant identifier.

tokens long

Number of tokens consumed.

ReleaseSession(string)

Decrements the concurrent session count for the given tenant.

public void ReleaseSession(string tenantId)

Parameters

tenantId string