In-process quota counters backed by ETS.
Summary
Functions
Adds usage to the rolling quota counter for a scope.
Ensures the quota ETS table exists.
Returns current usage snapshot for a scope.
Resets quota counters for a scope.
Returns quota status including limits, usage, and remaining budget.
Types
@type usage() :: %{ window_started_at_ms: non_neg_integer(), requests: non_neg_integer(), total_tokens: non_neg_integer() }
Functions
@spec add_usage(String.t(), non_neg_integer(), non_neg_integer()) :: usage()
Adds usage to the rolling quota counter for a scope.
@spec ensure_table!() :: :ok
Ensures the quota ETS table exists.
Returns current usage snapshot for a scope.
@spec reset(String.t()) :: :ok
Resets quota counters for a scope.
@spec status(String.t(), map(), non_neg_integer()) :: map()
Returns quota status including limits, usage, and remaining budget.