Snowflex. Transport behaviour
(Snowflex v1.7.2)
View Source
Behaviour module that defines the interface for Snowflake transport implementations.
See Snowflex.Transport.Http for the default implementation.
Summary
Callbacks
Request cancellation of a previously submitted statement.
Clean up cursor state after streaming is complete. See DBConnection.handle_deallocate/4 for more information.
Declare a statement (primarily for streaming) and return a cursor.
See DBConnection.handle_declare/4 for more information.
Disconnect from the database. See DBConnection.handle_close/3 for more information.
Execute a statement. See DBConnection.handle_execute/4 for more information.
Fetch the next result from a cursor. Return {:ok, result} while the cursor
may still hold more results and {:halt, result} once it is exhausted.
See DBConnection.handle_fetch/4 for more information.
Fetch the result of a previously submitted statement.
Periodic pings to the server, default is once per second. See DBConnection.ping/1 for more information.
Report the status of a previously submitted statement.
Submit a statement for execution and return as soon as the server acknowledges it, without waiting for the statement to finish.
Types
@type connection_opts() :: Keyword.t()
@type cursor() :: term()
@type fetch_result() :: {:ok, Snowflex.Result.t()} | {:halt, Snowflex.Result.t()} | {:error, Snowflex.Error.t()}
@type query_result() :: {:ok, Snowflex.Result.t()} | {:error, Snowflex.Error.t()}
@type status_result() :: {:ok, :running | :succeeded} | {:error, Snowflex.Error.t()}
Callbacks
@callback cancel_statement(pid(), String.t(), Keyword.t()) :: query_result()
Request cancellation of a previously submitted statement.
@callback deallocate(pid()) :: :ok
Clean up cursor state after streaming is complete. See DBConnection.handle_deallocate/4 for more information.
@callback declare(pid(), String.t(), any(), Keyword.t()) :: {:ok, cursor()} | {:error, Snowflex.Error.t()}
Declare a statement (primarily for streaming) and return a cursor.
See DBConnection.handle_declare/4 for more information.
@callback disconnect(pid()) :: :ok
Disconnect from the database. See DBConnection.handle_close/3 for more information.
@callback execute_statement(pid(), String.t(), any(), Keyword.t()) :: query_result()
Execute a statement. See DBConnection.handle_execute/4 for more information.
@callback fetch(pid(), cursor(), Keyword.t()) :: fetch_result()
Fetch the next result from a cursor. Return {:ok, result} while the cursor
may still hold more results and {:halt, result} once it is exhausted.
See DBConnection.handle_fetch/4 for more information.
@callback fetch_result(pid(), String.t(), Keyword.t()) :: {:ok, Snowflex.Result.t() | :running} | {:error, Snowflex.Error.t()}
Fetch the result of a previously submitted statement.
Returns {:ok, :running} if the statement has not finished yet, so a caller
can poll with this function alone. Once the statement has completed the full
result set is returned as {:ok, t:Snowflex.Result.t/0}.
@callback ping(pid()) :: query_result()
Periodic pings to the server, default is once per second. See DBConnection.ping/1 for more information.
@callback start_link(connection_opts()) :: GenServer.on_start()
@callback statement_status(pid(), String.t(), Keyword.t()) :: status_result()
Report the status of a previously submitted statement.
Returns {:ok, :running} while the statement is executing and
{:ok, :succeeded} once it has finished successfully. A statement that
finished with an error is reported as {:error, t:Snowflex.Error.t/0}.
@callback submit_async(pid(), String.t(), any(), Keyword.t()) :: query_result()
Submit a statement for execution and return as soon as the server acknowledges it, without waiting for the statement to finish.
The returned Snowflex.Result.t/0 carries the server's statement handle in
:query_id; it has no rows. Use statement_status/3 to check on the
statement later and cancel_statement/3 to stop it.