package polymarket

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Polymarket_rate_limiter.StateSource

State management for rate limiting.

This module manages GCRA states for all routes, providing thread-safe access. Call cleanup explicitly to remove stale entries.

Sourcetype t

State manager for all route limits

Sourcetype route_key = string

Unique key identifying a route (e.g., "api.example.com:GET:/orders")

Sourceval create : clock:_ Eio.Time.clock -> ?max_idle_time:float -> unit -> t

Create a state manager.

  • parameter clock

    Eio clock for timing

  • parameter max_idle_time

    Remove states unused for this long in seconds (default: 300.0)

Sourceval check_limits : t -> route_key:route_key -> limits:Types.limit_config list -> (unit, float) result

Check all limits for a route.

  • returns

    Ok () if all limits pass, Error max_retry_after if any limit is exceeded

Sourceval cleanup : t -> unit

Remove stale state entries (unused longer than max_idle_time)

Sourceval state_count : t -> int

Get the number of active state entries (for monitoring)

Sourceval reset : t -> unit

Clear all state (for testing)