CCXT.RateLimiter.State (ccxt_client v0.6.1)

Copy Markdown View Source

ETS-backed store for rate limit status across exchanges.

Stores the latest CCXT.RateLimiter.Info from each exchange response, keyed by {exchange_id, api_key | :public}. This allows consumers to query current rate limit pressure at any time.

Architecture

A GenServer owns the ETS table (OTP-idiomatic -- handles restarts cleanly). The table is :public with read_concurrency: true so any process can read without going through the GenServer.

Usage

case CCXT.RateLimiter.State.status("binance") do
  %Info{remaining: remaining} -> remaining
  nil -> :unknown
end

Summary

Functions

Returns all rate limit entries for an exchange.

Returns a specification to start this module under a supervisor.

Starts the State GenServer.

Returns the latest rate limit info for an exchange's public endpoints.

Returns the latest rate limit info for a specific exchange + credential key.

Updates the rate limit info for a given key.

Functions

all(exchange_id)

@spec all(String.t()) :: [CCXT.RateLimiter.Info.t()]

Returns all rate limit entries for an exchange.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the State GenServer.

status(exchange_id)

@spec status(String.t()) :: CCXT.RateLimiter.Info.t() | nil

Returns the latest rate limit info for an exchange's public endpoints.

status(exchange_id, credential_key)

@spec status(String.t(), term()) :: CCXT.RateLimiter.Info.t() | nil

Returns the latest rate limit info for a specific exchange + credential key.

update(key, info)

@spec update(
  {String.t(), term()},
  CCXT.RateLimiter.Info.t()
) :: :ok

Updates the rate limit info for a given key.

Key is {exchange_id, api_key | :public}.