Liking cljdoc? Tell your friends :D

stripe-clojure.http.throttle


create-throttlerclj

(create-throttler rate-limits)

Creates a per-instance throttler with the given rate limits.

Uses only the provided rate-limits without any defaults, since throttling is now opt-in only when users provide restrictive custom limits.

Parameters:

  • rate-limits: A map of custom rate limits

Returns: A Throttler record with the provided rate-limit configuration and an atom for limiter state.

Creates a per-instance throttler with the given rate limits.

Uses only the provided rate-limits without any defaults, since throttling
is now opt-in only when users provide restrictive custom limits.

Parameters:
- rate-limits: A map of custom rate limits

Returns:
A Throttler record with the provided rate-limit configuration and an atom for limiter state.
sourceraw docstring

with-throttlingclj

(with-throttling throttler method url api-key f)

Wraps the provided function f with throttling logic using the per-instance throttler.

TRUE ZERO-OVERHEAD DESIGN: When no throttler is provided (nil), there is literally zero overhead - the function executes directly with no additional logic.

Performance characteristics:

  • No throttler (nil): 0ns overhead (direct function call)
  • High rates (≥500 req/s): ~1-5µs overhead (just function call)
  • Normal rates (1-499 req/s): Full throttling with token bucket
  • Rate limit 0: Throttling disabled entirely

Note: Stripe's actual server limits are 25-100 req/s, so most client-side throttling will use the full token bucket algorithm.

Parameters:

  • throttler: A Throttler instance or nil (for zero overhead).
  • method: HTTP method keyword (:get, :post, etc.).
  • url: The full URL for the API endpoint.
  • api-key: Used to determine whether the requests are in test or live mode.
  • f: The function to execute once a token is acquired.

Returns: The result of invoking f after a token is successfully acquired.

Wraps the provided function `f` with throttling logic using the per-instance throttler.

TRUE ZERO-OVERHEAD DESIGN: When no throttler is provided (nil), there is literally
zero overhead - the function executes directly with no additional logic.

Performance characteristics:
- No throttler (nil): 0ns overhead (direct function call)
- High rates (≥500 req/s): ~1-5µs overhead (just function call)
- Normal rates (1-499 req/s): Full throttling with token bucket
- Rate limit 0: Throttling disabled entirely

Note: Stripe's actual server limits are 25-100 req/s, so most client-side
throttling will use the full token bucket algorithm.

Parameters:
- throttler: A Throttler instance or nil (for zero overhead).
- method: HTTP method keyword (:get, :post, etc.).
- url: The full URL for the API endpoint.
- api-key: Used to determine whether the requests are in test or live mode.
- f: The function to execute once a token is acquired.

Returns:
The result of invoking `f` after a token is successfully acquired.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close