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)
(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}](broker-stats b)Merged {:gate ... :heap ...} snapshot.
Merged {:gate ... :heap ...} snapshot.
(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.(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.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 |