Skip to content

KeyedRateLimiter<TKey>

Class in Oadm.Sdk.Network · Oadm.Sdk.dll

Token buckets per client key (address, MAC) in a bounded LRU table plus one global bucket, shared by the network service plugins (NTP, DHCP). Thread safe; no allocations in the steady state (table nodes are reused once the table is full or entries expire). Floods of new keys only ever cost one table entry each, never more than KeyedRateLimitOptions.MaxClients entries.

public sealed class KeyedRateLimiter<TKey>
KeyedRateLimiter(KeyedRateLimitOptions? options = null, TimeProvider? time = null)

A limiter with options (defaults when null).

int ClientCount { get; }

Clients currently tracked (bounded by KeyedRateLimitOptions.MaxClients).

KeyedRateLimitOptions Options { get; }

The limits.

RateLimitResult Check(TKey client)

Counts one request of client and says whether to handle it.

bool GloballyLimitedWithin(TimeSpan window)

The global limit dropped a request within window.