package polymarket
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=4eb4c5d2f63ff081c9713d90be5a51b2
sha512=0e3de0c9b40683e09ab8f9f966a44784ef1b9b482c3eefef84104a7e8042c92f1d79893ee9588b24fa3d0decaed7f365509f4d1c23c66ce8328efb64e721f276
doc/polymarket.rate_limiter/Polymarket_rate_limiter/Builder/index.html
Module Polymarket_rate_limiter.BuilderSource
Fluent 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
Pattern Matching
Rate Limits
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
Behavior
Set what happens when the rate limit is exceeded.
Delay: Sleep until the request can proceed (default)Error: Return an error immediately
Building
Build the final route configuration. Uses Delay behavior if not specified. At least one limit must be configured.
Convenience Constructors
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
Host-Scoped Builder
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