Skip to main content

Module ratelimit

Module ratelimit 

Source
Expand description

Cross-platform rate limiting.

Buckets key on archivist:ratelimit:<fichub_user_id> when the caller is linked to a FicHub account, so a spammer on Telegram gets throttled on Discord/Matrix/Web simultaneously. When the user is not linked, the bucket keys on archivist:ratelimit:<platform>:<ext_id> (per-platform fallback).

Sliding-window semantics are approximated with a simple fixed window: INCR + EXPIRE; when the counter exceeds limit inside the window the call is rejected.

Structs§

RateLimiter
Rate limiter over the shared Redis instance.

Constants§

DEFAULT_LIMIT
Default max commands per window per user.
DEFAULT_WINDOW_SECS
Default window length (seconds).