Bolt.Sips v1.2.1-rc2 Bolt.Sips.Protocol View Source
Implements callbacks required by DBConnection.
Each callback receives an open connection as a state.
Link to this section Summary
Functions
Callback for DBConnection.checkin/1
Callback for DBConnection.checkout/1
Callback for DBConnection.connect/1
Callback for DBConnection.disconnect/1
Callback for DBConnection.handle_begin/1
Close a query prepared by c:handle_prepare/3
with the database. Return
{:ok, result, state}
on success and to continue,
{:error, exception, state}
to return an error and continue, or
{:disconnect, exception, state}
to return an error and disconnect
Callback for DBConnection.handle_commit/1
Deallocate a cursor declared by c:handle_declare/4
with the database. Return
{:ok, result, state}
on success and to continue,
{:error, exception, state}
to return an error and continue, or
{:disconnect, exception, state}
to return an error and disconnect
Declare a cursor using a query prepared by c:handle_prepare/3
. Return
{:ok, query, cursor, state}
to return altered query query
and cursor
cursor
for a stream and continue, {:error, exception, state}
to return an
error and continue or {:disconnect, exception, state}
to return an error
and disconnect
Callback for DBConnection.handle_execute/1
Fetch the next result from a cursor declared by c:handle_declare/4
. Return
{:cont, result, state}
to return the result result
and continue using
cursor, {:halt, result, state}
to return the result result
and close the
cursor, {:error, exception, state}
to return an error and close the
cursor, {:disconnect, exception, state}
to return an error and disconnect
Prepare a query with the database. Return {:ok, query, state}
where
query
is a query to pass to execute/4
or close/3
,
{:error, exception, state}
to return an error and continue or
{:disconnect, exception, state}
to return an error and disconnect
Callback for DBConnection.handle_rollback/1
Handle getting the transaction status. Return {:idle, state}
if outside a
transaction, {:transaction, state}
if inside a transaction,
{:error, state}
if inside an aborted transaction, or
{:disconnect, exception, state}
to error and disconnect
Called when the connection has been idle for a period of time. Return
{:ok, state}
to continue or {:disconnect, exception, state}
to
disconnect
Link to this section Functions
checkin(sock) View Source
Callback for DBConnection.checkin/1
checkout(sock) View Source
Callback for DBConnection.checkout/1
connect(opts) View Source
Callback for DBConnection.connect/1
disconnect(err, sock) View Source
Callback for DBConnection.disconnect/1
handle_begin(opts, sock) View Source
Callback for DBConnection.handle_begin/1
handle_close(query, opts, state) View Source
Close a query prepared by c:handle_prepare/3
with the database. Return
{:ok, result, state}
on success and to continue,
{:error, exception, state}
to return an error and continue, or
{:disconnect, exception, state}
to return an error and disconnect.
This callback is called in the client process.
Callback implementation for DBConnection.handle_close/3
.
handle_commit(opts, sock) View Source
Callback for DBConnection.handle_commit/1
handle_deallocate(query, cursor, opts, state) View Source
Deallocate a cursor declared by c:handle_declare/4
with the database. Return
{:ok, result, state}
on success and to continue,
{:error, exception, state}
to return an error and continue, or
{:disconnect, exception, state}
to return an error and disconnect.
This callback is called in the client process.
Callback implementation for DBConnection.handle_deallocate/4
.
handle_declare(query, params, opts, state) View Source
Declare a cursor using a query prepared by c:handle_prepare/3
. Return
{:ok, query, cursor, state}
to return altered query query
and cursor
cursor
for a stream and continue, {:error, exception, state}
to return an
error and continue or {:disconnect, exception, state}
to return an error
and disconnect.
This callback is called in the client process.
Callback implementation for DBConnection.handle_declare/4
.
handle_execute(query, params, opts, sock) View Source
Callback for DBConnection.handle_execute/1
handle_fetch(query, cursor, opts, state) View Source
Fetch the next result from a cursor declared by c:handle_declare/4
. Return
{:cont, result, state}
to return the result result
and continue using
cursor, {:halt, result, state}
to return the result result
and close the
cursor, {:error, exception, state}
to return an error and close the
cursor, {:disconnect, exception, state}
to return an error and disconnect.
This callback is called in the client process.
Callback implementation for DBConnection.handle_fetch/4
.
handle_info(msg, state) View Source
handle_prepare(query, opts, state) View Source
Prepare a query with the database. Return {:ok, query, state}
where
query
is a query to pass to execute/4
or close/3
,
{:error, exception, state}
to return an error and continue or
{:disconnect, exception, state}
to return an error and disconnect.
This callback is intended for cases where the state of a connection is needed to prepare a query and/or the query can be saved in the database to call later.
This callback is called in the client process.
Callback implementation for DBConnection.handle_prepare/3
.
handle_rollback(opts, sock) View Source
Callback for DBConnection.handle_rollback/1
handle_status(opts, state) View Source
Handle getting the transaction status. Return {:idle, state}
if outside a
transaction, {:transaction, state}
if inside a transaction,
{:error, state}
if inside an aborted transaction, or
{:disconnect, exception, state}
to error and disconnect.
If the callback returns a :disconnect
tuples then status/2
will return
:error
.
Callback implementation for DBConnection.handle_status/2
.
ping(state) View Source
Called when the connection has been idle for a period of time. Return
{:ok, state}
to continue or {:disconnect, exception, state}
to
disconnect.
This callback is called if no callbacks have been called after the
idle timeout and a client process is not using the state. The idle
timeout can be configured by the :idle_interval
option. This function
can be called whether the connection is checked in or checked out.
This callback is called in the connection process.
Callback implementation for DBConnection.ping/1
.