Per-server concurrency limiter backed by ETS.
Tracks the number of in-flight requests per base_url using an atomic ETS
counter (:ets.update_counter/3). When the limit is reached subsequent
requests are rejected immediately — no blocking, no queue.
Configuration
Set max_concurrency per request or globally:
# Limit to 5 concurrent requests (non-blocking)
max_concurrency: 5
# No limit (default)
max_concurrency: :infinityBehaviour
- The limiter is checked before the HTTP dispatch.
acquire/2atomically increments the counter and returns:okif the slot is available, or{:error, %{code: :max_concurrency_reached}}.release/1decrements the counter after the request completes (success or failure).- ETS table is created lazily on first use — no supervision tree.
Summary
Functions
Acquire a concurrency slot for base_url.
Get the current in-flight count for base_url.
Release a concurrency slot for base_url.
Functions
Acquire a concurrency slot for base_url.
Returns :ok when the current in-flight count is below max_concurrency,
or {:error, %{code: :max_concurrency_reached, descr: _}} when at capacity.
Get the current in-flight count for base_url.
Release a concurrency slot for base_url.
Decrements the in-flight counter. Safe to call even after the limiter has been disabled or if the table is empty.