Liking cljdoc? Tell your friends :D

s-exp.flux

Clojure wrapper over Netflix concurrency-limits.

Core concepts:

  • A limiter controls inflight concurrency using an adaptive algorithm.
  • Calling acquire! attempts to get a token; returns a listener map on success, nil on rejection.
  • The listener must be finalized with success!, ignore!, or dropped!.
  • with-limit handles the acquire/finalize lifecycle automatically.
Clojure wrapper over Netflix concurrency-limits.

Core concepts:
- A `limiter` controls inflight concurrency using an adaptive algorithm.
- Calling `acquire!` attempts to get a token; returns a listener map on success, nil on rejection.
- The listener must be finalized with `success!`, `ignore!`, or `dropped!`.
- `with-limit` handles the acquire/finalize lifecycle automatically.
raw docstring

s-exp.flux.executor

Wraps BlockingAdaptiveExecutor — an java.util.concurrent.Executor whose thread-pool size is governed by an adaptive concurrency limiter.

Submitted tasks block the calling thread until a slot is available. The limiter observes each task's outcome:

  • success when the Runnable returns normally
  • dropped when it throws UncheckedTimeoutException or RejectedExecutionException
  • ignore on any other exception

Operations submitted should be homogeneous with similar latency profiles; the RTT feedback only comes from tasks that succeed.

Wraps BlockingAdaptiveExecutor — an java.util.concurrent.Executor whose
thread-pool size is governed by an adaptive concurrency limiter.

Submitted tasks block the calling thread until a slot is available. The
limiter observes each task's outcome:
  - success  when the Runnable returns normally
  - dropped  when it throws UncheckedTimeoutException or RejectedExecutionException
  - ignore   on any other exception

Operations submitted should be homogeneous with similar latency profiles;
the RTT feedback only comes from tasks that succeed.
raw docstring

s-exp.flux.ring

Ring middleware for concurrency limiting.

Usage:

(require '[s-exp.flux :as flux] '[s-exp.flux.ring :as flux.ring])

(def limiter (flux/simple-limiter (flux/vegas-limit {:max-concurrency 200})))

(def app (-> handler (flux.ring/wrap-concurrency-limit limiter)))

By default:

  • The context passed to the limiter is the Ring request map.
  • A 503 response is returned when the limit is exceeded.
  • 5xx responses (except 503 from the app itself) signal a drop.
  • All other responses signal success.

These behaviours are customisable via options.

Ring middleware for concurrency limiting.

Usage:

  (require '[s-exp.flux :as flux]
           '[s-exp.flux.ring :as flux.ring])

  (def limiter
    (flux/simple-limiter (flux/vegas-limit {:max-concurrency 200})))

  (def app
    (-> handler
        (flux.ring/wrap-concurrency-limit limiter)))

By default:
- The context passed to the limiter is the Ring request map.
- A 503 response is returned when the limit is exceeded.
- 5xx responses (except 503 from the app itself) signal a drop.
- All other responses signal success.

These behaviours are customisable via options.
raw 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