Safe Haskell | Safe-Infered |
---|
- type CPool = Pool Cassandra
- type Server = (HostName, Int)
- defServer :: Server
- defServers :: [Server]
- type KeySpace = String
- data Cassandra = Cassandra {}
- createCassandraPool :: [Server] -> Int -> Int -> NominalDiffTime -> KeySpace -> IO CPool
- withResource :: MonadBaseControl IO m => Pool a -> (a -> m b) -> m b
- openThrift :: (Integral a, HandleSource (t, PortID)) => t -> a -> IO (Handle, FramedTransport Handle, BinaryProtocol (FramedTransport Handle))
Documentation
defServers :: [Server]Source
A single localhost server with default configuration
MonadIO m => MonadCassandra (ReaderT CPool m) |
:: [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