Liking cljdoc? Tell your friends :D

pg.pool

A simple connection pool. Runs open connections in two data structures: a queue of free connections and a map of busy connections. The connections are taken from a tail of the queue and put back into the head.

Every time the connection is borrowed, it's check for expiration. An expired connection gets closed, and the one is produced.

Should all free connections are in use at the moment and the client is going to borrow another one, an exception is triggered.

When a connection is put back, it's checked for expiration and for the transaction status. Connections that are in the error state are closed; Connections that are in a transaction are rolled back.

A simple connection pool. Runs open connections in two
data structures: a queue of free connections and a map
of busy connections. The connections are taken from a tail
of the queue and put back into the head.

Every time the connection is borrowed, it's check for expiration.
An expired connection gets closed, and the one is produced.

Should all free connections are in use at the moment and the client
is going to borrow another one, an exception is triggered.

When a connection is put back, it's checked for expiration and for
the transaction status. Connections that are in the error state
are closed; Connections that are in a transaction are rolled back.
raw docstring

->pool-configclj

(->pool-config opt)

Build a PoolConfig instance from a Clojure map.

Build a PoolConfig instance from a Clojure map.
sourceraw docstring

borrow-connectionclj

(borrow-connection pool)

Borrow a connection from a pool.

Borrow a connection from a pool.
sourceraw docstring

closeclj

(close pool)

Close the pool by terminating all the connections, both free and used.

Close the pool by terminating all the connections,
both free and used.
sourceraw docstring

closed?clj

(closed? pool)

True if the pool has been closed before.

True if the pool has been closed before.
sourceraw docstring

free-countclj

(free-count pool)

Return the current number of free connections.

Return the current number of free connections.
sourceraw docstring

poolclj

(pool opt)

Run a new Pool from a config map.

Run a new Pool from a config map.
sourceraw docstring

pool?clj

(pool? x)

True if a value is a Pool instance.

True if a value is a Pool instance.
sourceraw docstring

statsclj

(stats pool)

Return both free and used connection amount as a map.

Return both free and used connection amount as a map.
sourceraw docstring

used-countclj

(used-count pool)

Return the current number of busy connections.

Return the current number of busy connections.
sourceraw docstring

with-connectioncljmacro

(with-connection [bind pool] & body)

Execute the body while the bind symbol is bound to a borrowed Connection instance. The connection is marked is busy and won't be available for other consumers. Return the connection to the pool when exiting the macro.

When no connections available, throw an exception.

Execute the body while the `bind` symbol is bound
to a borrowed Connection instance. The connection
is marked is busy and won't be available for other
consumers. Return the connection to the pool when
exiting the macro.

When no connections available, throw an exception.
sourceraw docstring

with-poolcljmacro

(with-pool [bind config] & body)

Execute the body while the bind symbol is bound to a new Pool instance. Close the pool afterwards.

Execute the body while the `bind` symbol is bound
to a new Pool instance. Close the pool afterwards.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close