Bolt.Sips v1.0.0-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, cursor, state} to start a cursor for a stream and continue, {: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

Callback for DBConnection.checkin/1

Callback for DBConnection.checkout/1

Callback for DBConnection.connect/1

Callback for DBConnection.disconnect/1

Link to this function handle_begin(opts, sock) View Source

Callback for DBConnection.handle_begin/1

Link to this function 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.

Link to this function handle_commit(opts, sock) View Source

Callback for DBConnection.handle_commit/1

Link to this function 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.

Link to this function handle_declare(query, params, opts, state) View Source

Declare a cursor using a query prepared by c:handle_prepare/3. Return {:ok, cursor, state} to start a cursor for a stream and continue, {: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.

Link to this function handle_execute(query, params, opts, sock) View Source

Callback for DBConnection.handle_execute/1

Link to this function 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.

Link to this function 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.

Link to this function handle_rollback(opts, sock) View Source

Callback for DBConnection.handle_rollback/1

Link to this function 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.

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_timeout 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.