StellaOps.Router.Gateway.RateLimiting.Valkey

Valkey store for the environment-scope rate limit of StellaOps.Router.Gateway

PackageStellaOps.Router.Gateway.RateLimiting.Valkey
ComponentRouter
LicenceBUSL-1.1 (Router licence)
Package kindLibrary
Target frameworknet10.0

To add the package to a project, see Installing Stella Ops packages.

Namespaces

NamespaceTypes
StellaOps.Router.Gateway.RateLimiting.Valkey2

StellaOps.Router.Gateway.RateLimiting.Valkey namespace

TypeKindDescription
RouterValkeyRateLimitStoreServiceCollectionExtensionsclassRegisters the Valkey store of the gateway’s environment-scope rate limit (rate_limiting:for_environment).
ValkeyRateLimitStoreclassValkey-backed fixed-window rate limit store.

RouterValkeyRateLimitStoreServiceCollectionExtensions class

public static class RouterValkeyRateLimitStoreServiceCollectionExtensions

Registers the Valkey store of the gateway’s environment-scope rate limit (rate_limiting:for_environment).

AddRouterValkeyRateLimitStore(IServiceCollection) extension method

public static IServiceCollection AddRouterValkeyRateLimitStore(this IServiceCollection services)

Registers ValkeyRateLimitStoreas the IValkeyRateLimitStoreof the environment rate limit. The store connects to rate_limiting:for_environment:valkey_connection and keeps its counters under valkey_bucket, read from the RateLimitConfigthat AddRouterRateLimiting registers; it is created only when environment rules are configured, and it connects on the first request. A store registered before this call is kept.

Parameters

Returns

The service collection for chaining.

ValkeyRateLimitStore class

public sealed class ValkeyRateLimitStore : IValkeyRateLimitStore, IDisposable

Valkey-backed fixed-window rate limit store.

ValkeyRateLimitStore(string, string, ILogger<ValkeyRateLimitStore>) constructor

public ValkeyRateLimitStore(string connectionString, string bucket, ILogger<ValkeyRateLimitStore>? logger = null)

Creates a store over a Valkey server.

Parameters

Dispose() method

public void Dispose()

See IDisposable.Dispose().

IncrementAndCheckAsync(string, IReadOnlyList<RateLimitRule>, CancellationToken) method

public Task<RateLimitStoreResult> IncrementAndCheckAsync(string key, IReadOnlyList<RateLimitRule> rules, CancellationToken cancellationToken)

Atomically increment counters for the provided rules and determine if the request is allowed.