hive-weave — bounded, timed, safe execution primitives.
Weaves parallel/concurrent/async strands with built-in safety: every operation has a timeout, every parallel fan-out is bounded.
Modules: hive-weave.safe — safe deref, safe future (never hangs) hive-weave.gate — semaphore-bounded execution hive-weave.parallel — bounded-pmap, fork-join, fan-out hive-weave.pool — bounded ThreadPoolExecutor + safe await! hive-weave.timed — timed interceptors, timed handlers
Quick start: (require '[hive-weave.core :as weave])
;; Safe deref (replaces bare @) (weave/deref-safe my-promise 5000 fallback)
;; Bounded parallel map (replaces pmap) (weave/bounded-pmap {:concurrency 4 :timeout-ms 5000} fetch-preview ids)
;; Fork-join with budget (weave/fork-join {:budget-ms 15000} [:tags #(query-tags tags) {}] [:kg #(expand-kg ids) #{}])
;; Gate for resource protection (def db-gate (weave/gate {:permits 4 :timeout-ms 10000 :name "db"})) (weave/with-gate db-gate (query ...))
;; Timed interceptor (for hive-events) (weave/->timed-interceptor :id :my/enrichment :timeout-ms 15000 :after (fn [ctx] ...))
hive-weave — bounded, timed, safe execution primitives.
Weaves parallel/concurrent/async strands with built-in safety:
every operation has a timeout, every parallel fan-out is bounded.
Modules:
hive-weave.safe — safe deref, safe future (never hangs)
hive-weave.gate — semaphore-bounded execution
hive-weave.parallel — bounded-pmap, fork-join, fan-out
hive-weave.pool — bounded ThreadPoolExecutor + safe await!
hive-weave.timed — timed interceptors, timed handlers
Quick start:
(require '[hive-weave.core :as weave])
;; Safe deref (replaces bare @)
(weave/deref-safe my-promise 5000 fallback)
;; Bounded parallel map (replaces pmap)
(weave/bounded-pmap {:concurrency 4 :timeout-ms 5000}
fetch-preview ids)
;; Fork-join with budget
(weave/fork-join {:budget-ms 15000}
[:tags #(query-tags tags) {}]
[:kg #(expand-kg ids) #{}])
;; Gate for resource protection
(def db-gate (weave/gate {:permits 4 :timeout-ms 10000 :name "db"}))
(weave/with-gate db-gate (query ...))
;; Timed interceptor (for hive-events)
(weave/->timed-interceptor
:id :my/enrichment :timeout-ms 15000
:after (fn [ctx] ...))Pool-bound counterpart to guarded-future-call. Submits to a ThreadPoolExecutor (via hive-weave.pool/make-pool) and applies the same timeout / cleanup / alert contract, plus pool-stats embedded in the alert event so saturation is visible when timeouts cluster.
Pool-bound counterpart to guarded-future-call. Submits to a ThreadPoolExecutor (via hive-weave.pool/make-pool) and applies the same timeout / cleanup / alert contract, plus pool-stats embedded in the alert event so saturation is visible when timeouts cluster.
(guarded-future opts & body)Macro form of guarded-future-call. Body is wrapped as the thunk.
Macro form of guarded-future-call. Body is wrapped as the thunk.
Run a thunk under :timeout-ms with cleanup hook + injectable alert.
On timeout: future-cancel, run :on-cancel on a separate cleanup pool,
fire :alert!, return (r/err :weave/timeout {...}). See
hive-weave.guarded ns doc for the full contract.
Run a thunk under :timeout-ms with cleanup hook + injectable alert.
On timeout: future-cancel, run :on-cancel on a separate cleanup pool,
fire :alert!, return (r/err :weave/timeout {...}). See
`hive-weave.guarded` ns doc for the full contract.(with-guarded-await pool opts & body)Macro form of guarded-await!. Submits body to pool with cleanup + alert hooks.
Macro form of guarded-await!. Submits body to pool with cleanup + alert hooks.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |