Paysafe.RateLimiter (Paysafe v1.0.0)

Copy Markdown View Source

Token-bucket rate limiter backed by ExRated.

Each Config gets its own bucket keyed by username. The default rate is 100 requests/second, configurable via :rate_limit in config.

Summary

Functions

Check and consume one token for the given config.

Functions

check(config)

@spec check(Paysafe.Config.t()) :: :ok | {:error, Paysafe.Error.t()}

Check and consume one token for the given config.

Returns :ok if the request can proceed, or {:error, %Error{}} if the rate limit has been exceeded.