import { ILogEntry, ILogFilterOptions, LogFilter } from "@spinajs/log-common"; /** * Options for {@link RateLimitFilter}. */ export interface IRateLimitFilterOptions extends ILogFilterOptions { /** Max entries kept per window. Required. */ limit: number; /** Fixed window length in SECONDS. Required. */ intervalSeconds: number; /** Variable field used to bucket the limit ( eg. per-logger ). Global if unset. */ key?: string; } interface IWindowRecord { count: number; windowStart: number; } /** * Fixed-window rate limiter. Keeps at most `limit` entries per `intervalSeconds` * window, bucketed by `entry.Variables[key]` when `key` is given ( else a single * global bucket ). Overflow entries within a window are DROPPED; the counter * resets when the window elapses. The bucket map is self-pruning ( stale windows * dropped on access ) so memory stays bounded. Clock is injectable for tests. */ export declare class RateLimitFilter extends LogFilter { protected now: () => number; protected limit: number; protected intervalMs: number; protected keyField?: string; protected windows: Map; constructor(options?: IRateLimitFilterOptions, now?: () => number); protected keyOf(entry: ILogEntry): string; apply(entry: ILogEntry): ILogEntry | null; /** Drops windows whose interval has fully elapsed so the map stays bounded. */ protected prune(now: number): void; } export {}; //# sourceMappingURL=RateLimitFilter.d.ts.map