Cassandra v1.0.0-beta.1 Cassandra.Cluster

Represents a cassandra cluster. It serves as a Session factory and a collection of metadata.

It always keeps a control connection open to one of cluster hosts to get notified about topological and status changes in the cluster, and keeps its metadata is sync.

Summary

Functions

Returns the all known hosts of a cluster as map with IPs as key and Cassandra.Host structs as values

Starts a Cluster process without links (outside of a supervision tree)

Starts a Cluster process linked to the current process

Functions

hosts(cluster)

Returns the all known hosts of a cluster as map with IPs as key and Cassandra.Host structs as values

start(contact_points \\ ["127.0.0.1"], options \\ [], gen_server_options \\ [])

Starts a Cluster process without links (outside of a supervision tree).

See start_link/3 for more information.

start_link(contact_points \\ ["127.0.0.1"], options \\ [], gen_server_options \\ [])

Starts a Cluster process linked to the current process.

contact_points is the initial list of addresses. Note that the entire list of cluster members will be discovered automatically once a connection to any hosts from the original list is successful.

Options

These are options which will be used to connect to contact_points.

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

For gen_server_options values see GenServer.start_link/3.

Return values

It returns {:ok, pid} when connection to one of contact_points established and metadata fetched, on any error it returns {:error, reason}.