DBConnection.run

You're seeing just the function run, go back to DBConnection module for more information.
Link to this function

run(conn, fun, opts \\ [])

View Source

Specs

run(conn(), (t() -> result), opts :: Keyword.t()) :: result when result: var

Acquire a lock on a connection and run a series of requests on it.

The return value of this function is the return value of fun.

To use the locked connection call the request with the connection reference passed as the single argument to the fun. If the connection disconnects all future calls using that connection reference will fail.

run/3 and transaction/3 can be nested multiple times but a transaction/3 call inside another transaction/3 will be treated the same as run/3.

Options

  • :queue - Whether to block waiting in an internal queue for the connection's state (boolean, default: true). See "Queue config" in start_link/2 docs
  • :timeout - The maximum time that the caller is allowed to perform this operation (default: 15_000)
  • :deadline - If set, overrides :timeout option and specifies absolute monotonic time in milliseconds by which caller must perform operation. See System module documentation for more information on monotonic time (default: nil)

The pool may support other options.

Example

{:ok, res} = DBConnection.run(conn, fn conn ->
  DBConnection.execute!(conn, query, [])
end)