Stateful wrappers for automatically reconnecting network clients.
A wrapper is a map with a connection atom conn
and a pair of functions:
(open)
, which opens a new connection, and (close conn)
, which closes a
connection. We use these to provide a with-conn macro that acquires the
current connection from a wrapper, evaluates body, and automatically
closes/reopens the connection when errors occur.
Connect/close/reconnect lock the wrapper, but multiple threads may acquire the current connection at once.
Stateful wrappers for automatically reconnecting network clients. A wrapper is a map with a connection atom `conn` and a pair of functions: `(open)`, which opens a new connection, and `(close conn)`, which closes a connection. We use these to provide a with-conn macro that acquires the current connection from a wrapper, evaluates body, and automatically closes/reopens the connection when errors occur. Connect/close/reconnect lock the wrapper, but multiple threads may acquire the current connection at once.
(conn wrapper)
Active connection for a wrapper, if one exists.
Active connection for a wrapper, if one exists.
(open! wrapper)
Given a wrapper, opens a connection. Noop if conn is already open.
Given a wrapper, opens a connection. Noop if conn is already open.
(reopen! wrapper)
Reopens a wrapper's connection.
Reopens a wrapper's connection.
(with-conn [c wrapper] & body)
Acquires a read lock, takes a connection from the wrapper, and evaluates body with that connection bound to c. If any Exception is thrown, closes the connection and opens a new one.
Acquires a read lock, takes a connection from the wrapper, and evaluates body with that connection bound to c. If any Exception is thrown, closes the connection and opens a new one.
(with-lock wrapper lock-method & body)
(with-read-lock wrapper & body)
(with-write-lock wrapper & body)
(wrapper options)
A wrapper is a stateful construct for talking to a database. Options:
:name An optional name for this wrapper (for debugging logs) :open A function which generates a new conn :close A function which closes a conn :log? Whether to log reconnect messages
A wrapper is a stateful construct for talking to a database. Options: :name An optional name for this wrapper (for debugging logs) :open A function which generates a new conn :close A function which closes a conn :log? Whether to log reconnect messages
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close