cassy-0.7.1: A high level driver for the Cassandra datastore

Safe HaskellNone

Database.Cassandra.Pool

Contents

Synopsis

Documentation

type CPool = Pool CassandraSource

A round-robin pool of cassandra connections

type Server = (HostName, Int)Source

A (ServerName, Port) tuple

defServer :: ServerSource

A localhost server with default configuration

defServers :: [Server]Source

A single localhost server with default configuration

createCassandraPoolSource

Arguments

:: [Server]

List of servers to connect to

-> Int

Number of stripes to maintain

-> Int

Max connections per stripe

-> NominalDiffTime

Kill each connection after this many seconds

-> KeySpace

Each pool operates on a single KeySpace

-> IO CPool 

Create a pool of connections to a cluster of Cassandra boxes

Each box in the cluster will get up to n connections. The pool will send queries in round-robin fashion to balance load on each box in the cluster.

withResource :: MonadBaseControl IO m => Pool a -> (a -> m b) -> m b

Temporarily take a resource from a Pool, perform an action with it, and return it to the pool afterwards.

  • If the pool has an idle resource available, it is used immediately.
  • Otherwise, if the maximum number of resources has not yet been reached, a new resource is created and used.
  • If the maximum number of resources has been reached, this function blocks until a resource becomes available.

If the action throws an exception of any type, the resource is destroyed, and not returned to the pool.

It probably goes without saying that you should never manually destroy a pooled resource, as doing so will almost certainly cause a subsequent user (who expects the resource to be valid) to throw an exception.

Low Level Utilities

openThrift :: (Integral a, HandleSource (t, PortID)) => t -> a -> IO (Handle, FramedTransport Handle, BinaryProtocol (FramedTransport Handle))Source

Open underlying thrift connection