Polymarket_rate_limiter.BuilderSourceFluent builder for rate limit configurations.
This module provides a chainable API for building route configurations, similar to the Rust route-ratelimit crate.
Example:
route () |> host "api.example.com" |> method_ "POST" |> path "/orders"
|> limit ~requests:100 ~window_seconds:10.0
|> limit ~requests:1000 ~window_seconds:600.0
|> on_limit Delay |> buildBuilder state
Multiple limits can be applied to the same route. All limits must pass for a request to proceed. This enables burst + sustained limit patterns.
Add a rate limit. Can be called multiple times to add multiple limits. Example: limit ~requests:100 ~window_seconds:10.0 for 100 req/10s
Set what happens when the rate limit is exceeded.
Delay: Sleep until the request can proceed (default)Error: Return an error immediatelyBuild the final route configuration. Uses Delay behavior if not specified. At least one limit must be configured.
val simple :
?host:string ->
?method_:string ->
?path:string ->
requests:int ->
window_seconds:float ->
?behavior:Types.behavior ->
unit ->
Types.route_configCreate a simple route configuration with a single limit. Example:
simple ~host:"api.example.com" ~requests:100 ~window_seconds:10.0 ()val global :
requests:int ->
window_seconds:float ->
behavior:Types.behavior ->
Types.route_configCreate a global rate limit that matches all routes
val per_host :
host:string ->
requests:int ->
window_seconds:float ->
behavior:Types.behavior ->
Types.route_configCreate a rate limit for all routes to a specific host
val per_endpoint :
host:string ->
method_:string ->
path:string ->
requests:int ->
window_seconds:float ->
behavior:Types.behavior ->
Types.route_configCreate a rate limit for a specific endpoint
For organizing rate limits by host, similar to the Rust library's .host("...", |h| ...) pattern.
Builder for routes scoped to a host
Start building routes for a specific host
Add a route to the host builder. The route inherits the host.
Build all routes for this host