Table of Contents

Class QuotaService

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

Implements the FoundationaLLM quota service.

public class QuotaService : IQuotaService
Inheritance
QuotaService
Implements
Inherited Members
Extension Methods

Constructors

QuotaService(DependencyInjectionContainerSettings, IStorageService, IEventService, ILoggerFactory)

Initializes a new instance of the QuotaService class.

public QuotaService(DependencyInjectionContainerSettings dependencyInjectionContainerSettings, IStorageService storageService, IEventService eventService, ILoggerFactory loggerFactory)

Parameters

dependencyInjectionContainerSettings DependencyInjectionContainerSettings

The DependencyInjectionContainerSettings providing the configuration of the dependency injection container.

storageService IStorageService

The storage service used for storing quota configuration.

eventService IEventService

The IEventService providing event services to the quota service.

loggerFactory ILoggerFactory

The logger factory used to create loggers.

Properties

Enabled

Indicates whether the quota service is enabled.

public bool Enabled { get; }

Property Value

bool

InitializationTask

Gets the TaskCompletionSource<TResult> (TResult of type bool) that signals the completion of the initialization task.

public Task<bool> InitializationTask { get; }

Property Value

Task<bool>

Remarks

The result of the task indicates whether initialization completed successfully or not.

Methods

EvaluateCompletionRequestForQuota(string, string, UnifiedUserIdentity?, CompletionRequest)

Evaluates a completion request to determine if it exceeds any quotas.

public QuotaMetricPartitionState EvaluateCompletionRequestForQuota(string apiName, string controllerName, UnifiedUserIdentity? userIdentity, CompletionRequest completionRequest)

Parameters

apiName string

The name of the API handling the request.

controllerName string

The name of the ASP.NET controller handling the request.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing the user identity associated with the request.

completionRequest CompletionRequest

The CompletionRequest providing the completion request details.

Returns

QuotaMetricPartitionState

EvaluateRawRequestForQuota(string, string?, UnifiedUserIdentity?)

Evaluates an HTTP API request to determine if it exceeds any quotas.

public QuotaMetricPartitionState EvaluateRawRequestForQuota(string apiName, string? controllerName, UnifiedUserIdentity? userIdentity)

Parameters

apiName string

The name of the API handling the request.

controllerName string

The name of the ASP.NET controller handling the request.

userIdentity UnifiedUserIdentity

The UnifiedUserIdentity providing the user identity associated with the request.

Returns

QuotaMetricPartitionState

An QuotaMetricPartitionState object that indicates if any quotas where exceeded and provides details in case of a quota breach.