Table of Contents

Class QuotaContextBase

Namespace
FoundationaLLM.Common.Services.Quota
Assembly
FoundationaLLM.Common.dll

Implements the base class for managing the in-memory state of a quota context.

public abstract class QuotaContextBase
Inheritance
QuotaContextBase
Derived
Inherited Members
Extension Methods

Constructors

QuotaContextBase(string, QuotaDefinition, ILogger)

Implements the base class for managing the in-memory state of a quota context.

protected QuotaContextBase(string quotaServiceIdentifier, QuotaDefinition quota, ILogger logger)

Parameters

quotaServiceIdentifier string

The identifier of the QuotaService instance managing this quota context.

quota QuotaDefinition

The QuotaDefinition providing the quota configuration.

logger ILogger

The logger used for logging.

Fields

_logger

The logger used for logging.

protected readonly ILogger _logger

Field Value

ILogger

_metricPartitions

The dictionary of QuotaMetricPartition instances that correspond to the partition identifiers.

protected readonly Dictionary<string, QuotaMetricPartition> _metricPartitions

Field Value

Dictionary<string, QuotaMetricPartition>

Remarks

Each derived class must implement the specific methods to get the quota metric partition that corresponds to the partition identifier.

_quota

The QuotaDefinition providing the quota configuration.

protected readonly QuotaDefinition _quota

Field Value

QuotaDefinition

_quotaServiceIdentifier

The identifier of the QuotaService instance managing this quota context.

protected readonly string _quotaServiceIdentifier

Field Value

string

_syncRoot

The object used to synchronize access to the quota context.

protected readonly object _syncRoot

Field Value

object

Properties

Quota

Gets or sets the context.

public QuotaDefinition Quota { get; }

Property Value

QuotaDefinition

Methods

AddLocalMetricUnit(DateTimeOffset, string, string)

Adds a new local unit of the quota metric to the quota context and checks if the quota is exceeded or not.

public QuotaMetricPartitionState AddLocalMetricUnit(DateTimeOffset referenceTime, string userIdentifier, string userPrincipalName)

Parameters

referenceTime DateTimeOffset

The time at which the local metric unit was recorded.

userIdentifier string

The user identifier associated with the unit of the quota metric.

userPrincipalName string

The user principal name associated with the unit of the quota metric.

Returns

QuotaMetricPartitionState

The result of the quota evaluation.

AddRemoteMetricUnits(List<DateTimeOffset>, string)

Adds remote units of the quota metric to the quota context.

public void AddRemoteMetricUnits(List<DateTimeOffset> referenceTimes, string partitionId)

Parameters

referenceTimes List<DateTimeOffset>

The times at which the remote metric units were recorded.

partitionId string

The quota metric partition identifier.

EnsureQuotaMetricPartition(string)

Ensures that the quota metric partition corresponding to the specified partition identifier exists.

protected QuotaMetricPartition EnsureQuotaMetricPartition(string partitionId)

Parameters

partitionId string

The quota metric partition identifier.

Returns

QuotaMetricPartition

GetQuotaMetricPartition(string)

Gets the quota metric partition that corresponds to the specified partition identifier.

protected virtual QuotaMetricPartition GetQuotaMetricPartition(string partitionId)

Parameters

partitionId string

The quota metric partition id.

Returns

QuotaMetricPartition

A QuotaMetricPartition instance.

GetQuotaMetricPartition(string, string)

Gets the quota metric partition that corresponds to the specified user identifier and/or user principal name.

protected abstract QuotaMetricPartition GetQuotaMetricPartition(string userIdentifier, string userPrincipalName)

Parameters

userIdentifier string

The user identifier used to get the quota metric partition

userPrincipalName string

The user principal name used to get the quota metric partition.

Returns

QuotaMetricPartition

A QuotaMetricPartition instance.