Rate limiter facade used by GamendWeb.Plugs.RateLimiter, LiveView
helpers, and channels.
Delegates to one of two Hammer-powered backends:
GamendWeb.RateLimit.ETS(default) — node-local counters.GamendWeb.RateLimit.Redis— counters shared across all app instances via Redis; use this for multi-instance deployments so limits hold cluster-wide.
Configuration
config :gamend_web, GamendWeb.RateLimit,
backend: :redis,
redis: [url: "redis://localhost:6379"]Selected at runtime via the RATE_LIMIT_BACKEND env var ("ets" or
"redis"); the Redis URL falls back to RATE_LIMIT_REDIS_URL,
CACHE_REDIS_URL, then REDIS_URL.
The configured backend is started in the host application supervision tree.
Summary
Functions
Returns the currently configured backend module.
Daily chat quota for one user (Gamend.Limits :max_chat_messages_per_day,
rolling 24h window). Returns :ok or {:error, :chat_daily_limit}.
Daily chat-report quota for one user (Gamend.Limits
:max_chat_reports_per_user_per_day, rolling 24h window). Returns :ok or
{:error, :report_daily_limit}.
Functions
@spec backend() :: module()
Returns the currently configured backend module.
@spec check_chat_daily(term()) :: :ok | {:error, :chat_daily_limit}
Daily chat quota for one user (Gamend.Limits :max_chat_messages_per_day,
rolling 24h window). Returns :ok or {:error, :chat_daily_limit}.
Skipped when rate limiting is disabled or the limit is 0.
@spec check_report_daily(term()) :: :ok | {:error, :report_daily_limit}
Daily chat-report quota for one user (Gamend.Limits
:max_chat_reports_per_user_per_day, rolling 24h window). Returns :ok or
{:error, :report_daily_limit}.
Skipped when rate limiting is disabled or the limit is 0.
@spec hit(String.t(), pos_integer(), pos_integer()) :: {:allow, non_neg_integer()} | {:deny, non_neg_integer()}