Cassandra v1.0.0-beta.1 Cassandra.Session

Session is a server for handling query execution.

Summary

Functions

Executes the query with given options on session

Prepares the query for later execution

Sends request through session

Starts a session on the cluster with given options, linked to current process

Functions

execute(session, query, options \\ [])

Executes the query with given options on session.

If query is not prepared, session prepares it automatically.

Return values

{:ok, :done} when cassandra response is VOID in response to some queries

{:ok, data} where data is one of the following structs:

{:error, {code, message}} when cassandra response is an error

prepare(session, statement)

Prepares the query for later execution.

It returns {:ok, query} on success and {:error, {code, message}} when cassandra response is an error

send(session, request)

Sends request through session.

request must be a CQL.Request.

Return values

{:ok, :done} when cassandra response is VOID in response to some queries

{:ok, :ready} when cassandra response is READY in response to Register requests

{:ok, data} where data is one of the following structs:

{:error, {code, message}} when cassandra response is an error

start_link(cluster, options \\ [], gen_server_options \\ [])

Starts a session on the cluster with given options, linked to current process.

Options

  • :balancer - Cassandra.LoadBalancing.Policy to use
  • :port - Cassandra native protocol port (default: 9042)
  • :connection_timeout - connection timeout in milliseconds (defult: 5000)
  • :timeout - query execution timeout in milliseconds (default: :infinity)
  • :keyspace - name of keyspace to bind session to
  • :reconnection_policy - module which implements Cassandra.Reconnection.Policy (defult: Exponential)
  • :reconnection_args - list of arguments to pass to :reconnection_policy on init (defult: [])

Retutns {:ok, pid} or {:error, reason}.