Liking cljdoc? Tell your friends :D
Clojure only.

co.multiply.remontoire.patterns.cleanup

Stateful cleanup around async work: open, lend, release — however the work settles. __q/finally is the handler for it, because it is the only one that also runs on cancellation: an eval can be cancelled by id at any moment, and a resource opened inside one must not leak when it is.

Stateful cleanup around async work: open, lend, release — however the
work settles. `__q/finally` is the handler for it, because it is the
only one that also runs on cancellation: an eval can be cancelled by
id at any moment, and a resource opened inside one must not leak when
it is.
raw docstring

with-resourceclj

(with-resource acquire release f)

The loan pattern — the async with-open: acquire a resource, lend it to f (resource → task), and release it however f's task settles: success, failure, or cancellation. The resource is bound outside the chain, so release does not depend on how far f got; callers see f's own result untouched, because finally never transforms. release is called synchronously — if release is itself async, wrap its creation in __q/compel, since the chain is already settling and will not wait for what a handler returns.

The loan pattern — the async `with-open`: `acquire` a resource, lend
it to `f` (resource → task), and `release` it however `f`'s task
settles: success, failure, or cancellation. The resource is bound
outside the chain, so release does not depend on how far `f` got;
callers see `f`'s own result untouched, because `finally` never
transforms. `release` is called synchronously — if release is itself
async, wrap its *creation* in `__q/compel`, since the chain is already
settling and will not wait for what a handler returns.
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