MentorAgent Docs
Menu

Questa pagina non è ancora tradotta in italiano: qui la trovi in inglese.

ReferencePackage: Novior.MentorAgent

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.

Namespace: Novior.MentorAgent.Core. Package: Novior.MentorAgent.

public sealed class MentorRateLimiter

Terminal
dotnet add package Novior.MentorAgent

public MentorRateLimiter(IOptions<MentorOptions> options)

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.

public int GetSecondsUntilReset(string userId)

Returns the seconds remaining before the window resets for the given user.