Header menu logo FSharp.ATProto

RateLimiter Module

In-memory sliding window rate limiter. Tracks requests per key (typically client IP or DID) within a configurable window.

Types

Type Description

RateLimiterState

A rate limiter instance that can be shared across requests. Internal implementation uses a ConcurrentDictionary of timestamp lists.

Functions and values

Function or value Description

create config

Full Usage: create config

Parameters:
Returns: RateLimiterState

Create a new rate limiter for the given config.

config : RateLimitConfig
Returns: RateLimiterState

tryAllow key now state

Full Usage: tryAllow key now state

Parameters:
Returns: Result<int, float>

Try to allow a request for the given key. Returns Ok with the number of remaining requests, or Error with the seconds until the window resets.

key : string
now : DateTimeOffset
state : RateLimiterState
Returns: Result<int, float>

Type something to start searching.