Liking cljdoc? Tell your friends :D

hive-weave.broker

Resource broker — combines a budget gate (cost-based admission) with a heap sentinel (JVM pressure signal). Consumers (hive-mcp, hive-knowledge, ...) depend on IResourceBroker; the default impl applies a policy table at submit-time:

:normal → pass through with caller's timeout :high → extend timeout (heap pressure: give GC headroom) :critical → reject-fast with :retry-after-ms (don't compound pressure)

Resource broker — combines a budget gate (cost-based admission) with a heap
sentinel (JVM pressure signal). Consumers (hive-mcp, hive-knowledge, ...)
depend on IResourceBroker; the default impl applies a policy table at
submit-time:

  :normal   → pass through with caller's timeout
  :high     → extend timeout (heap pressure: give GC headroom)
  :critical → reject-fast with :retry-after-ms (don't compound pressure)
raw docstring

decide-policyclj

(decide-policy state
               base-timeout-ms
               {:keys [high-timeout-multiplier critical-retry-after-ms]
                :or {high-timeout-multiplier 2.0 critical-retry-after-ms 1000}})

Pure: (state base-timeout-ms opts) → [action arg]. Action variants: [:pass timeout-ms] [:extend timeout-ms] ; surface as extended-timeout pass-through [:reject {:retry-after-ms N :state :critical}]

Pure: (state base-timeout-ms opts) → [action arg].
Action variants:
  [:pass   timeout-ms]
  [:extend timeout-ms]   ; surface as extended-timeout pass-through
  [:reject {:retry-after-ms N :state :critical}]
sourceraw docstring

default-policy-optsclj

source

IResourceBrokercljprotocol

broker-statsclj

(broker-stats b)

Merged {:gate ... :heap ...} snapshot.

Merged {:gate ... :heap ...} snapshot.

submitclj

(submit b workload)

Workload: {:cost N :thunk fn :timeout-ms? N}. Returns Result. Errors: :broker/heap-critical, :budget/over-capacity, :budget/timeout, :budget/execution-failed.

Workload: {:cost N :thunk fn :timeout-ms? N}. Returns Result.
Errors: :broker/heap-critical, :budget/over-capacity, :budget/timeout,
:budget/execution-failed.
source

start-broker!clj

(start-broker!)
(start-broker! {:keys [gate-opts sentinel-opts policy-opts]
                :or {gate-opts {:capacity 4096 :unit :mib :name "broker-gate"}
                     sentinel-opts {:name "broker-heap"}
                     policy-opts {}}})

Options: :gate-opts — passed to byte-budget-gate (default {:capacity 4096 :unit :mib :name "broker-gate"}) :sentinel-opts — passed to start-sentinel! (default {:name "broker-heap"}) :policy-opts — merged onto default-policy-opts (default {})

Caller must stop-broker! to release the sentinel's scheduler.

Options:
  :gate-opts     — passed to byte-budget-gate
                   (default {:capacity 4096 :unit :mib :name "broker-gate"})
  :sentinel-opts — passed to start-sentinel!
                   (default {:name "broker-heap"})
  :policy-opts   — merged onto default-policy-opts
                   (default {})

Caller must stop-broker! to release the sentinel's scheduler.
sourceraw docstring

stop-broker!clj

(stop-broker! b)
source

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