Liking cljdoc? Tell your friends :D

hive-addon.lifecycle

Addon lifecycle boundary: mount on first use, release after idle, keep what is pinned, and release idle parts of what stays.

(def mgr (lifecycle/manager {:host h :specs specs :defaults {:policy :eager} :overrides {"hive.carto" {:policy :lazy :idle-ms 900000}} :surface-store (store/edn-dir-store dir)})) (lifecycle/boot! mgr) ; mounts eager, stubs dormant (lifecycle/install! mgr) ; dormancy oracle + the installed manager (lifecycle/start-sweeper! mgr)

A stub call runs activate!; a real handler runs inside with-use, which counts it in flight and touches the addon. sweep! evicts what the pure plan (hive-addon.lifecycle.policy/sweep-plan) allows and closes idle parts.

Activations and evictions are serialized by one reentrant lock. An eviction moves :active to :evicting only while nothing is in flight, and a use only starts on an :active addon, so no call runs on an addon being shut down.

Addon lifecycle boundary: mount on first use, release after idle, keep what is
pinned, and release idle parts of what stays.

  (def mgr (lifecycle/manager {:host h :specs specs
                               :defaults {:policy :eager}
                               :overrides {"hive.carto" {:policy :lazy :idle-ms 900000}}
                               :surface-store (store/edn-dir-store dir)}))
  (lifecycle/boot! mgr)          ; mounts eager, stubs dormant
  (lifecycle/install! mgr)       ; dormancy oracle + the installed manager
  (lifecycle/start-sweeper! mgr)

A stub call runs `activate!`; a real handler runs inside `with-use`, which
counts it in flight and touches the addon. `sweep!` evicts what the pure plan
(hive-addon.lifecycle.policy/sweep-plan) allows and closes idle parts.

Activations and evictions are serialized by one reentrant lock. An eviction
moves :active to :evicting only while nothing is in flight, and a use only
starts on an :active addon, so no call runs on an addon being shut down.
raw docstring

activate!clj

(activate! mgr id)

Mount ID and every dependency it lacks. Idempotent: an active addon answers :already-active? true. Returns an ActivationReport.

Mount ID and every dependency it lacks. Idempotent: an active addon answers
:already-active? true. Returns an ActivationReport.
sourceraw docstring

active?clj

(active? mgr id)
source

adopt!clj

(adopt! mgr specs)

Govern SPECS that are ALREADY mounted (hot inject, a host's own boot) as active addons under the resolved policy. Returns the adopted ids.

Govern SPECS that are ALREADY mounted (hot inject, a host's own boot) as active
addons under the resolved policy. Returns the adopted ids.
sourceraw docstring

boot!clj

(boot! mgr)
(boot! mgr {:keys [mount-eager?] :or {mount-eager? true}})

Mount what the policy says mounts at boot and stub the rest. OPTS {:mount-eager? false} records eager addons as active without mounting them, for a host that mounted them itself. Returns a BootReport.

Mount what the policy says mounts at boot and stub the rest.
OPTS {:mount-eager? false} records eager addons as active without mounting
them, for a host that mounted them itself. Returns a BootReport.
sourceraw docstring

call-with-useclj

(call-with-use mgr id f)

Call F with ID counted in flight. An ungoverned ID runs F untracked. A dormant ID is activated first; when that fails F is not called and the ActivationReport is thrown as ex-info.

Call F with ID counted in flight. An ungoverned ID runs F untracked. A dormant
ID is activated first; when that fails F is not called and the
ActivationReport is thrown as ex-info.
sourceraw docstring

default-lock-timeout-msclj

source

default-sweep-interval-msclj

source

dormant?clj

(dormant? mgr id)

True for an addon this manager governs that is not mounted.

True for an addon this manager governs that is not mounted.
sourceraw docstring

evict!clj

(evict! mgr id)
(evict! mgr id {:keys [force?]})

Release ID: shut it down, withdraw its surface, advertise stubs. Refuses while it is in flight or an active addon depends on it. OPTS {:force? true} also evicts a pinned or eager addon. Returns an EvictionReport.

Release ID: shut it down, withdraw its surface, advertise stubs. Refuses while
it is in flight or an active addon depends on it. OPTS {:force? true} also
evicts a pinned or eager addon. Returns an EvictionReport.
sourceraw docstring

install!clj

(install! mgr)

Make MGR the installed manager and the source of the dormancy oracle.

Make MGR the installed manager and the source of the dormancy oracle.
sourceraw docstring

installed-managerclj

(installed-manager)
source

managerclj

(manager {:keys [host specs] :as opts})

A lifecycle manager. OPTS: :host ILifecycleHost (required) :specs [MountSpec ...] every addon this manager governs :defaults LifecycleDecl applied under each manifest's own :overrides {addon-id LifecycleDecl}, strongest :surface-store ISurfaceStore for learned surfaces :now-ms (fn [] ms) :reload-ns! (fn [roots ns-strs] -> reloader answer) run before an activation mounts; default uses hive-hot when present :on-activated (fn [ids]) after addons become active :on-evicted (fn [id]) after an addon becomes dormant :lock-timeout-ms

A lifecycle manager. OPTS:
:host           ILifecycleHost (required)
:specs          [MountSpec ...] every addon this manager governs
:defaults       LifecycleDecl applied under each manifest's own
:overrides      {addon-id LifecycleDecl}, strongest
:surface-store  ISurfaceStore for learned surfaces
:now-ms         (fn [] ms)
:reload-ns!     (fn [roots ns-strs] -> reloader answer) run before an
                activation mounts; default uses hive-hot when present
:on-activated   (fn [ids]) after addons become active
:on-evicted     (fn [id]) after an addon becomes dormant
:lock-timeout-ms
sourceraw docstring

mount-hostclj

(mount-host mh)
(mount-host mh mount-opts)

An ILifecycleHost over an IMountHost. Stubs are kept in an atom ({id {:surface s :activate! f}}) readable as (:stubs host).

An ILifecycleHost over an IMountHost. Stubs are kept in an atom
({id {:surface s :activate! f}}) readable as (:stubs host).
sourceraw docstring

phaseclj

(phase mgr id)
source

set-policy!clj

(set-policy! mgr id decl)

Change ID's lifecycle at runtime (e.g. pin it). Returns the new Lifecycle.

Change ID's lifecycle at runtime (e.g. pin it). Returns the new Lifecycle.
sourceraw docstring

start-sweeper!clj

(start-sweeper! mgr)
(start-sweeper! mgr {:keys [interval-ms]})

Sweep every :sweep-interval-ms on a daemon thread. Idempotent.

Sweep every :sweep-interval-ms on a daemon thread. Idempotent.
sourceraw docstring

stateclj

(state mgr id)
source

statusclj

(status mgr)

The manager as wire-safe data.

The manager as wire-safe data.
sourceraw docstring

stop-sweeper!clj

(stop-sweeper! mgr)
source

surface-ofclj

(surface-of mgr id)

[surface source] for ID: declared, else learned, else [nil :none].

[surface source] for ID: declared, else learned, else [nil :none].
sourceraw docstring

sweep!clj

(sweep! mgr)

Evict every addon the sweep plan allows, then close idle parts. Returns {:plan SweepPlan :evicted [id ...] :refused {id reason} :parts {owner [part-id]}}.

Evict every addon the sweep plan allows, then close idle parts.
Returns {:plan SweepPlan :evicted [id ...] :refused {id reason} :parts {owner [part-id]}}.
sourceraw docstring

sweep-planclj

(sweep-plan mgr)
source

touch!clj

(touch! mgr id)

Mark ID used now.

Mark ID used now.
sourceraw docstring

trackedclj

(tracked mgr id f)

F wrapped so every call counts as a use of ID.

F wrapped so every call counts as a use of ID.
sourceraw docstring

uninstall!clj

(uninstall!)
source

with-usecljmacro

(with-use mgr id & body)

Run BODY with addon ID counted in flight (see call-with-use).

Run BODY with addon ID counted in flight (see call-with-use).
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