Jido.AI.Quota.Store (Jido AI v2.2.0)

Copy Markdown View Source

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

usage()

@type usage() :: %{
  window_started_at_ms: non_neg_integer(),
  requests: non_neg_integer(),
  total_tokens: non_neg_integer()
}

Functions

add_usage(scope, tokens, window_ms)

@spec add_usage(String.t(), non_neg_integer(), non_neg_integer()) :: usage()

Adds usage to the rolling quota counter for a scope.

ensure_table!()

@spec ensure_table!() :: :ok

Ensures the quota ETS table exists.

get(scope)

@spec get(String.t()) :: usage()

Returns current usage snapshot for a scope.

reset(scope)

@spec reset(String.t()) :: :ok

Resets quota counters for a scope.

status(scope, limits, window_ms)

@spec status(String.t(), map(), non_neg_integer()) :: map()

Returns quota status including limits, usage, and remaining budget.