Liking cljdoc? Tell your friends :D

clunk.async

clunk's core.async API: query as a channel of rows, <query!, connect as a channel, and listen as a channel of notifications, built on the sinks, cancel tokens and listeners of clunk.core. clunk doesn't depend on core.async, so add org.clojure/core.async to your own dependencies to use this namespace.

clunk's core.async API: query as a channel of rows, <query!, connect as
a channel, and listen as a channel of notifications, built on the sinks,
cancel tokens and listeners of clunk.core. clunk doesn't depend on
core.async, so add org.clojure/core.async to your own dependencies to
use this namespace.
raw docstring

<query!clj/smacro

(<query! client sql)

Inside a go block, parks until the query finishes and returns a vector of all its rows (and any error).

Inside a go block, parks until the query finishes and returns a vector of
all its rows (and any error).
sourceraw docstring

connectclj/s

(connect client)

Starts the connection, as clunk.core/connect does, and returns a channel that yields the server's ReadyForQuery message, or an error.

Starts the connection, as clunk.core/connect does, and returns a channel
that yields the server's ReadyForQuery message, or an error.
sourceraw docstring

listenclj/s

(listen client channel-name)
(listen client channel-name {:keys [max-queued] :or {max-queued 1000}})

Listens for notifications on channel-name, as clunk.core/listen does, and returns a channel of them. The connection never waits for it: a channel with :max-queued (default 1000) notifications not yet taken gets an error value instead and closes. If LISTEN fails, or the connection drops, it gets an error value and closes; clunk/close closes it with no error. To stop, call clunk.core/unlisten with the channel; closing it yourself stops it too, as the next notification on channel-name arrives.

Listens for notifications on channel-name, as clunk.core/listen does, and
returns a channel of them. The connection never waits for it: a channel
with :max-queued (default 1000) notifications not yet taken gets an error
value instead and closes. If LISTEN fails, or the connection drops, it
gets an error value and closes; clunk/close closes it with no error. To
stop, call clunk.core/unlisten with the channel; closing it yourself
stops it too, as the next notification on channel-name arrives.
sourceraw docstring

queryclj/s

(query client sql)
(query client sql {:keys [cancel fetch-size]})

Queues a query on a client or a pool and returns a channel of row maps, keyed by column name, that closes after the last row. A failed query puts an error on the channel. sql is a string or a vector of a statement and its parameters, as for clunk.core/query.

To stop early, pass a :cancel channel, such as a promise-chan or a timeout, and close it or put on it: the returned channel closes and the client discards the rest of the result. A query still waiting for a pool's connection doesn't run at all. Closing the returned channel alone can leave the client waiting to put a row, holding up every later query.

With :cancel, the server sends the rows in batches of :fetch-size (1000 unless given), so cancelling also stops the server after the current batch. Such a query, like one with parameters, is one statement.

Queues a query on a client or a pool and returns a channel of row maps,
keyed by column name, that closes after the last row. A failed query puts
an error on the channel. sql is a string or a vector of a statement and
its parameters, as for clunk.core/query.

To stop early, pass a :cancel channel, such as a promise-chan or a timeout,
and close it or put on it: the returned channel closes and the client
discards the rest of the result. A query still waiting for a pool's
connection doesn't run at all. Closing the returned channel alone can
leave the client waiting to put a row, holding up every later query.

With :cancel, the server sends the rows in batches of :fetch-size (1000
unless given), so cancelling also stops the server after the current
batch. Such a query, like one with parameters, is one statement.
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