Liking cljdoc? Tell your friends :D

ottla.connection

A single database connection, opened from a conn-map, that is replaced after it fails. Used by listeners and workers, which each need a session of their own: the listener for LISTEN, the worker for its group's advisory lock.

After a failure, the next connection is opened no sooner than reconnect-ms later. connection! doesn't wait for that: it returns nil until then, and wait-ms says how long is left, for callers that would rather sleep.

A connection is meant to be used from one thread at a time. Closing it (.close, or ottla.protocols/graceful-shutdown) and status may be called from any thread.

A single database connection, opened from a conn-map, that is replaced
after it fails. Used by listeners and workers, which each need a session
of their own: the listener for LISTEN, the worker for its group's
advisory lock.

After a failure, the next connection is opened no sooner than
`reconnect-ms` later. `connection!` doesn't wait for that: it returns
nil until then, and `wait-ms` says how long is left, for callers that
would rather sleep.

A connection is meant to be used from one thread at a time. Closing it
(`.close`, or `ottla.protocols/graceful-shutdown`) and `status` may be
called from any thread.
raw docstring

drop-if-broken!clj

(drop-if-broken! db-conn)

After an error, check the connection, and if it's broken, treat it as failed (see failed!). Returns true if it was dropped.

After an error, check the connection, and if it's broken, treat it as
failed (see `failed!`). Returns true if it was dropped.
sourceraw docstring

IDbConnectioncljprotocol

connection!clj

(connection! db-conn)

The open connection, connecting first if there is none. Returns nil while it's too soon after a failure to reconnect, and once closed. Throws if connecting fails, and counts that as a failure.

The open connection, connecting first if there is none. Returns nil
while it's too soon after a failure to reconnect, and once closed.
Throws if connecting fails, and counts that as a failure.

failed!clj

(failed! db-conn)

Report that the connection failed: close it, and reconnect on a later connection!, once reconnect-ms has passed.

Report that the connection failed: close it, and reconnect on a later
`connection!`, once `reconnect-ms` has passed.

healthy?clj

(healthy? db-conn)

Whether there is an open connection, and it answers a query.

Whether there is an open connection, and it answers a query.

wait-msclj

(wait-ms db-conn)

How long until connection! may reconnect: 0 when connected, or when a reconnect may be attempted now.

How long until `connection!` may reconnect: 0 when connected, or when
a reconnect may be attempted now.
source

reconnection-connectionclj

(reconnection-connection conn-map {:keys [reconnect-ms label]})

A reconnecting connection from conn-map. Nothing connects until the first connection!.

  • :reconnect-ms how long to wait after a failure before reconnecting
  • :label names the connection in log messages
A reconnecting connection from `conn-map`. Nothing connects until the
first `connection!`.
  - `:reconnect-ms` how long to wait after a failure before reconnecting
  - `:label`        names the connection in log messages
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