Liking cljdoc? Tell your friends :D

hive-milvus.circuit

Circuit breaker for Milvus protocol operations.

States: :closed (normal) | :open (fail-fast) | :half-open (probing).

Flow:

  • :closed - calls pass through. N consecutive connection failures (threshold) -> :open with opened-at=now.
  • :open - check returns {:success? false :error :circuit-open :retry-after ms :reconnecting? true} until cooldown-ms has elapsed since opened-at.
  • cooldown elapsed - next check transitions to :half-open and allows the call through as a probe. record-success! closes the breaker and notifies subscribers; record-failure! reopens it (resets opened-at=now).

Subscribers: callers can subscribe! a 0-arity fn invoked on every :closed transition (open->closed or half-open->closed). Used by the queue drain module to flush buffered writes when Milvus is healthy.

Thread-safety: single atom, swap! transitions; listener fns run on the caller's thread that closed the breaker (keep them fast or spawn futures inside).

Time discipline: routes wall-clock through hive-ttracking.clock/now-millis so tests can pin time deterministically — never call System/currentTimeMillis directly.

Circuit breaker for Milvus protocol operations.

States: :closed (normal) | :open (fail-fast) | :half-open (probing).

Flow:
- :closed - calls pass through. N consecutive connection failures
  (threshold) -> :open with opened-at=now.
- :open - `check` returns {:success? false :error :circuit-open
  :retry-after ms :reconnecting? true} until cooldown-ms has elapsed
  since opened-at.
- cooldown elapsed - next `check` transitions to :half-open and allows
  the call through as a probe. `record-success!` closes the breaker
  and notifies subscribers; `record-failure!` reopens it (resets
  opened-at=now).

Subscribers: callers can `subscribe!` a 0-arity fn invoked on every
:closed transition (open->closed or half-open->closed). Used by the
queue drain module to flush buffered writes when Milvus is healthy.

Thread-safety: single atom, swap! transitions; listener fns run on
the caller's thread that closed the breaker (keep them fast or spawn
futures inside).

Time discipline: routes wall-clock through `hive-ttracking.clock/now-millis`
so tests can pin time deterministically — never call
`System/currentTimeMillis` directly.
raw docstring

checkclj

(check)

Gate a protocol call against the breaker.

Returns nil when the call is allowed (:closed or :half-open probe). Returns a fail map when :open and still in cooldown:

{:success? false :error :circuit-open :retry-after <ms remaining> :reconnecting? true}

Side effect: transitions :open -> :half-open when cooldown has elapsed, so the next caller gets a probe slot.

Gate a protocol call against the breaker.

Returns nil when the call is allowed (:closed or :half-open probe).
Returns a fail map when :open and still in cooldown:

  {:success?      false
   :error         :circuit-open
   :retry-after   <ms remaining>
   :reconnecting? true}

Side effect: transitions :open -> :half-open when cooldown has
elapsed, so the next caller gets a probe slot.
sourceraw docstring

closed?clj

(closed?)
source

configure!clj

(configure! {:keys [threshold cooldown-ms]})

Update breaker tunables without changing :state. Accepts {:threshold N :cooldown-ms ms} - only non-nil keys are merged.

Update breaker tunables without changing :state. Accepts
{:threshold N :cooldown-ms ms} - only non-nil keys are merged.
sourceraw docstring

force-reset!clj

(force-reset!)

Force the breaker back to fresh :closed state. Intended for tests and manual admin recovery. Does NOT notify listeners.

Force the breaker back to fresh :closed state. Intended for tests
and manual admin recovery. Does NOT notify listeners.
sourceraw docstring

half-open?clj

(half-open?)
source

open?clj

(open?)
source

record-failure!clj

(record-failure!)

Record a connection-failure outcome. State transitions:

  • :closed -> inc failures; if failures>=threshold trip :open.
  • :half-open -> trip back to :open (probe failed).
  • :open -> no-op (cooldown already running).
Record a connection-failure outcome. State transitions:

- :closed    -> inc failures; if failures>=threshold trip :open.
- :half-open -> trip back to :open (probe failed).
- :open      -> no-op (cooldown already running).
sourceraw docstring

record-success!clj

(record-success!)

Record a successful outcome. State transitions:

  • :closed -> reset failures to 0.
  • :half-open -> close the breaker, reset failures, notify listeners.
  • :open -> close the breaker, reset failures, notify listeners (defensive: should not normally happen because :open short-circuits via check).
Record a successful outcome. State transitions:

- :closed    -> reset failures to 0.
- :half-open -> close the breaker, reset failures, notify listeners.
- :open      -> close the breaker, reset failures, notify listeners
                (defensive: should not normally happen because :open
                short-circuits via `check`).
sourceraw docstring

stateclj

(state)

Return the current breaker state map.

Return the current breaker state map.
sourceraw docstring

subscribe!clj

(subscribe! f)

Register a 0-arity fn to be invoked on every transition to :closed. Returns the registered fn. Duplicate registrations are no-ops.

Register a 0-arity fn to be invoked on every transition to :closed.
Returns the registered fn. Duplicate registrations are no-ops.
sourceraw docstring

unsubscribe!clj

(unsubscribe! f)

Deregister a previously-subscribed listener fn.

Deregister a previously-subscribed listener fn.
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