Liking cljdoc? Tell your friends :D

vaelii.impl.disk.durability

Durability management for the disk backend. Each disk store/kv registers itself here on open; one daemon fsyncs every registrant on a tick (default 3 s), and one JVM shutdown hook closes them all on exit. Without it, a crash between manual fsyncs loses everything since the last one.

Registration is capability-based — callers hand in {:fsync :close :label} (plus an optional {:compact :dead-ratio} for background compaction), so this namespace does not depend on the stores it drives (which would cycle).

Config (system properties): vaelii.disk.sync-ms (tick interval, 0 disables the daemon), vaelii.disk.auto-compact (off with false/0/off), vaelii.disk.compact-dead-ratio (default 0.5), vaelii.disk.compact-min-interval-ms (default 300000).

Durability management for the disk backend.  Each disk store/kv registers itself
here on open; one daemon fsyncs every registrant on a tick (default 3 s), and one
JVM shutdown hook closes them all on exit.  Without it, a crash between manual
fsyncs loses everything since the last one.

Registration is capability-based — callers hand in `{:fsync :close :label}` (plus an
optional `{:compact :dead-ratio}` for background compaction), so this namespace does
not depend on the stores it drives (which would cycle).

Config (system properties): `vaelii.disk.sync-ms` (tick interval, 0 disables the
daemon), `vaelii.disk.auto-compact` (off with `false`/`0`/`off`),
`vaelii.disk.compact-dead-ratio` (default 0.5),
`vaelii.disk.compact-min-interval-ms` (default 300000).
raw docstring

auto-compact?clj

(auto-compact?)

Is background/opportunistic compaction enabled (vaelii.disk.auto-compact)? Public because the close path consults the same switch the tick does — one knob, not two.

Is background/opportunistic compaction enabled (`vaelii.disk.auto-compact`)?  Public
because the close path consults the same switch the tick does — one knob, not two.
raw docstring

call-with-compaction-pausedclj

(call-with-compaction-paused thunk)

Run thunk with background auto-compaction paused, resuming on the way out (even on throw). A no-op in effect when no disk backend is registered.

Run `thunk` with background auto-compaction paused, resuming on the way out (even on
throw).  A no-op in effect when no disk backend is registered.
raw docstring

compact-dead-ratioclj

(compact-dead-ratio)

The dead-ratio a log must reach to be worth compacting (vaelii.disk.compact-dead-ratio, default 0.5). Public for the same reason.

The dead-ratio a log must reach to be worth compacting
(`vaelii.disk.compact-dead-ratio`, default 0.5).  Public for the same reason.
raw docstring

deregister!clj

(deregister! id)

Remove a registered backend. Idempotent.

Remove a registered backend.  Idempotent.
raw docstring

pause-compaction!clj

(pause-compaction!)

Suspend the daemon's background auto-compaction across every registered backend. For a bulk load, whose monotonic delta accumulation trips the dead-ratio trigger repeatedly and would rewrite a growing multi-GB index mid-load — stalling the writer on the backend lock each time — pause for the load's duration and let the next tick compact once afterwards. Idempotent; pair with resume-compaction!, or wrap the load in call-with-compaction-paused. Only the daemon's automatic firing is gated: a manual compact! and the dead-ratio bookkeeping are untouched.

Suspend the daemon's background auto-compaction across every registered backend.
For a bulk load, whose monotonic delta accumulation trips the dead-ratio trigger
repeatedly and would rewrite a growing multi-GB index mid-load — stalling the writer
on the backend lock each time — pause for the load's duration and let the next tick
compact once afterwards.  Idempotent; pair with `resume-compaction!`, or wrap the load
in `call-with-compaction-paused`.  Only the daemon's automatic firing is gated: a
manual `compact!` and the dead-ratio bookkeeping are untouched.
raw docstring

register!clj

(register! {:keys [fsync close label] :as entry})

Register a disk backend with the durability manager. Entry keys: :fsync (fn [{:keys [fsync?]}], required), :close (fn [], required), :label (string, required), and optionally :compact (fn []) + :dead-ratio (fn [] → double) for background compaction. Returns an id for deregister!; starts the scheduler and installs the shutdown hook on first registration.

Register a disk backend with the durability manager.  Entry keys: `:fsync` (fn
`[{:keys [fsync?]}]`, required), `:close` (fn `[]`, required), `:label` (string,
required), and optionally `:compact` (fn `[]`) + `:dead-ratio` (fn `[]` → double)
for background compaction.  Returns an id for `deregister!`; starts the scheduler
and installs the shutdown hook on first registration.
raw docstring

resume-compaction!clj

(resume-compaction!)

Re-enable background auto-compaction paused by pause-compaction!. The next flush tick compacts any backend whose dead ratio has crossed the threshold.

Re-enable background auto-compaction paused by `pause-compaction!`.  The next flush
tick compacts any backend whose dead ratio has crossed the threshold.
raw docstring

stop!clj

(stop!)

Stop the schedulers (REPL/test teardown). Leaves the shutdown hook installed.

Stop the schedulers (REPL/test teardown).  Leaves the shutdown hook installed.
raw 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