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

Database.Cassandra.Pool

Synopsis

Documentation

type CPool = Pool Cassandra ServerSource

A round-robin pool of cassandra connections

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

Max connections per server (n)

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

newtype Pool a s Source

Constructors

Pool 

Fields

stripes :: TVar (Ring (Stripe a s))
 

withPool :: Pool a s -> (a -> IO b) -> IO bSource

data Ring a Source

Constructors

Ring 

Fields

current :: !a
 
used :: [a]
 
upcoming :: [a]
 

next :: Ring a -> Ring aSource

data Stripe a s Source

Constructors

Stripe 

Fields

idle :: TVar [Connection a]

FIFO buffer of idle connections

inUse :: TVar Int

Set of in-use connections

server :: s

Server this strip is connected to

create :: s -> IO a

Create action

destroy :: a -> IO ()

Destroy action

cxns :: Int

Max connections

ttl :: NominalDiffTime

TTL for each connection

createStripe :: (s -> IO a) -> (a -> IO ()) -> Int -> NominalDiffTime -> s -> IO (Stripe a s)Source

withStripe :: Stripe a s -> (a -> IO b) -> IO bSource

data Connection a Source

Constructors

Connection 

Fields

cxn :: a
 
lastUse :: UTCTime
 

modifyTVar_ :: TVar a -> (a -> a) -> STM ()Source