Questa pagina non è ancora tradotta in italiano: qui la trovi in inglese.
MentorRateLimiter class
The MentorRateLimiter class of Novior.MentorAgent.Core: Rate limiter for user messages — in-memory, per session. Algorithm: sliding window counter. Each…
On this page
Rate limiter for user messages — in-memory, per session. Algorithm: sliding window counter. Each userId has a counter and the window start timestamp. When the window expires, the counter resets. Registered as Singleton — shares state across all users. Thread-safe via lock. Disabled if RateLimitPerUser = 0.
Definition
Section titled “Definition”Namespace: Novior.MentorAgent.Core. Package: Novior.MentorAgent.
public sealed class MentorRateLimiter
dotnet add package Novior.MentorAgentConstructors
Section titled “Constructors”public MentorRateLimiter(IOptions<MentorOptions> options)
Methods
Section titled “Methods”CheckAndIncrement
Section titled “CheckAndIncrement”public ValueTuple<bool, int> CheckAndIncrement(string userId)
Checks whether the user is allowed to send a message. Increments the counter if allowed.
Returns: (allowed: true, remaining: N) if allowed, (allowed: false, remaining: 0) if limit reached.
GetSecondsUntilReset
Section titled “GetSecondsUntilReset”public int GetSecondsUntilReset(string userId)
Returns the seconds remaining before the window resets for the given user.
