Liking cljdoc? Tell your friends :D

hive-weave.gate

Concurrency gate — bounded-permit execution with timeout.

A gate wraps a java.util.concurrent.Semaphore with:

  • Timeout-aware permit acquisition
  • Result integration (gate-run returns ok/err instead of throwing)
  • Diagnostics (available permits, queue length)

Three ways to use:

  1. with-gate — bracket macro, throws on timeout
  2. gate-run — function, returns Result
  3. deref-gate — gated deref for promises/futures with timeout

Also satisfies hive-weave.budget/IBudgetGate so consumers can depend on the unit-agnostic protocol regardless of whether the underlying gate is slot-permit-based (this ns) or byte-cost-based (hive-weave.budget).

Usage: (def db-read (gate {:permits 4 :timeout-ms 15000 :name "db-read"}))

(with-gate db-read (query-database ...)) (deref-gate db-read (chroma/query coll embedding))

Concurrency gate — bounded-permit execution with timeout.

A gate wraps a java.util.concurrent.Semaphore with:
- Timeout-aware permit acquisition
- Result integration (gate-run returns ok/err instead of throwing)
- Diagnostics (available permits, queue length)

Three ways to use:

1. `with-gate` — bracket macro, throws on timeout
2. `gate-run`  — function, returns Result
3. `deref-gate` — gated deref for promises/futures with timeout

Also satisfies hive-weave.budget/IBudgetGate so consumers can depend on
the unit-agnostic protocol regardless of whether the underlying gate is
slot-permit-based (this ns) or byte-cost-based (hive-weave.budget).

Usage:
  (def db-read (gate {:permits 4 :timeout-ms 15000 :name "db-read"}))

  (with-gate db-read (query-database ...))
  (deref-gate db-read (chroma/query coll embedding))
raw docstring

deref-gateclj

(deref-gate g derefable)
(deref-gate g derefable timeout-ms)

Deref a promise/future under the gate's permit with timeout. Replaces bare @(chroma/query ...) with bounded concurrency + timeout.

Deref a promise/future under the gate's permit with timeout.
Replaces bare `@(chroma/query ...)` with bounded concurrency + timeout.
sourceraw docstring

gateclj

(gate {:keys [permits timeout-ms name fair?]
       :or {permits 1 timeout-ms 30000 name "gate" fair? true}})

Create a concurrency gate.

Options: :permits — max concurrent executions (default 1, i.e. serialized) :timeout-ms — max wait for permit acquisition (default 30000) :name — diagnostic name (default "gate") :fair? — FIFO ordering for waiters (default true)

Create a concurrency gate.

Options:
  :permits    — max concurrent executions (default 1, i.e. serialized)
  :timeout-ms — max wait for permit acquisition (default 30000)
  :name       — diagnostic name (default "gate")
  :fair?      — FIFO ordering for waiters (default true)
sourceraw docstring

gate-runclj

(gate-run g f)

Execute f under the gate's permit. Returns Result.

On success: (ok <return-value>) On timeout: (err :gate/timeout {...}) On error: (err :gate/execution-failed {...})

Execute f under the gate's permit. Returns Result.

On success: (ok <return-value>)
On timeout: (err :gate/timeout {...})
On error:   (err :gate/execution-failed {...})
sourceraw docstring

gate-run!clj

(gate-run! g f)

Execute f under the gate's permit. Throws on timeout.

Execute f under the gate's permit. Throws on timeout.
sourceraw docstring

gate-statsclj

(gate-stats g)

Current gate state for diagnostics.

Current gate state for diagnostics.
sourceraw docstring

with-gatecljmacro

(with-gate g & body)

Execute body under gate permit. Throws on timeout.

(with-gate db-read (query-database ...))

Execute body under gate permit. Throws on timeout.

(with-gate db-read (query-database ...))
sourceraw docstring

with-gate-resultcljmacro

(with-gate-result g & body)

Execute body under gate permit. Returns Result.

(with-gate-result db-write (insert-record! ...))

Execute body under gate permit. Returns Result.

(with-gate-result db-write (insert-record! ...))
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