StellaOps.Router.Gateway.RateLimiting.Valkey
Valkey store for the environment-scope rate limit of StellaOps.Router.Gateway
| Package | StellaOps.Router.Gateway.RateLimiting.Valkey |
| Component | Router |
| Licence | BUSL-1.1 (Router licence) |
| Package kind | Library |
| Target framework | net10.0 |
To add the package to a project, see Installing Stella Ops packages.
Namespaces
| Namespace | Types |
|---|---|
StellaOps.Router.Gateway.RateLimiting.Valkey | 2 |
StellaOps.Router.Gateway.RateLimiting.Valkey namespace
| Type | Kind | Description |
|---|---|---|
RouterValkeyRateLimitStoreServiceCollectionExtensions | class | Registers the Valkey store of the gateway’s environment-scope rate limit (rate_limiting:for_environment). |
ValkeyRateLimitStore | class | Valkey-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
services: The service collection.
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
connectionString: The Valkey connection string.bucket: The key prefix that separates this store’s counters.logger: Receives the store diagnostics; none when not set.
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.
