Liking cljdoc? Tell your friends :D

hive-addon.lifecycle.part

Parts: resources an addon owns that can be released while the addon stays mounted, and reopened on the next use.

A part is opened by its first acquire!, touched by every use, and closed by a sweep once it has been idle for its :idle-ms with nothing using it. Closing releases the resource (a cache, an index, a connection pool, a model); the part itself stays registered and opens again when next acquired.

(def index (part/part {:id :carto/index :idle-ms 600000 :open (fn [] (load-index)) :close (fn [idx] (release idx))})) (part/register-part! "hive.carto" index) (part/with-part [idx index] (query idx q))

Closing never deletes data: :close releases what :open acquired.

Parts: resources an addon owns that can be released while the addon stays
mounted, and reopened on the next use.

A part is opened by its first `acquire!`, touched by every use, and closed by
a sweep once it has been idle for its :idle-ms with nothing using it. Closing
releases the resource (a cache, an index, a connection pool, a model); the
part itself stays registered and opens again when next acquired.

  (def index (part/part {:id :carto/index :idle-ms 600000
                         :open  (fn [] (load-index))
                         :close (fn [idx] (release idx))}))
  (part/register-part! "hive.carto" index)
  (part/with-part [idx index] (query idx q))

Closing never deletes data: :close releases what :open acquired.
raw docstring

acquire!clj

(acquire! p)

The part's resource, opening it first when closed. Touches the part. Throws what :open throws; the part stays closed in that case.

The part's resource, opening it first when closed. Touches the part.
Throws what :open throws; the part stays closed in that case.
sourceraw docstring

begin-use!clj

(begin-use! p)

Acquire P and count one use in flight. Pair with end-use!.

Acquire P and count one use in flight. Pair with end-use!.
sourceraw docstring

close!clj

(close! p)

Close P now unless a use is in flight. Returns :closed, :already-closed or :in-flight. A :close that throws is recorded; the part still counts as closed.

Close P now unless a use is in flight. Returns :closed, :already-closed or
:in-flight. A :close that throws is recorded; the part still counts as closed.
sourceraw docstring

close-owner!clj

(close-owner! owner)

Close every part of OWNER and forget them. Returns the ids closed now.

Close every part of OWNER and forget them. Returns the ids closed now.
sourceraw docstring

end-use!clj

(end-use! p)
source

idle?clj

(idle? p now)

True when P is open, unused, and untouched for its :idle-ms as of NOW.

True when P is open, unused, and untouched for its :idle-ms as of NOW.
sourceraw docstring

open?clj

(open? p)
source

ownersclj

(owners)
source

partclj

(part {:keys [id idle-ms open close clock]})

A closed part. OPTS: :id keyword, unique within its owner :idle-ms idle time before a sweep may close it :open (fn [] resource) :close (fn [resource]), optional :clock (fn [] ms), optional, for tests

A closed part. OPTS:
:id       keyword, unique within its owner
:idle-ms  idle time before a sweep may close it
:open     (fn [] resource)
:close    (fn [resource]), optional
:clock    (fn [] ms), optional, for tests
sourceraw docstring

parts-ofclj

(parts-of owner)

{part-id Part} registered under OWNER.

{part-id Part} registered under OWNER.
sourceraw docstring

register-part!clj

(register-part! owner p)

Register P under OWNER (an addon id). A part already registered under the same id is closed and replaced. Returns P.

Register P under OWNER (an addon id). A part already registered under the same
id is closed and replaced. Returns P.
sourceraw docstring

reset-registry!clj

(reset-registry!)

Close and forget every part. For tests.

Close and forget every part. For tests.
sourceraw docstring

statusclj

(status p)

P as data.

P as data.
sourceraw docstring

statusesclj

(statuses)

{owner [part-status ...]}.

{owner [part-status ...]}.
sourceraw docstring

sweep!clj

(sweep! now)

Close every idle part as of NOW. Returns {owner [part-id ...]} for the parts closed.

Close every idle part as of NOW. Returns {owner [part-id ...]} for the parts
closed.
sourceraw docstring

with-partcljmacro

(with-part [sym p] & body)

Bind SYM to P's resource for BODY, holding P open for its duration.

Bind SYM to P's resource for BODY, holding P open for its duration.
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