Safe Haskell | None |
---|
Haskell client for Cassandra's CQL protocol
This module isn't properly documented yet. For now, take a look at tests/example.hs.
Credentials are not implemented yet.
Here's the correspondence between Haskell and CQL types. Not all Cassandra data types supported as yet: Haskell types listed below have been implemented.
- type Server = (HostName, ServiceName)
- createCassandraPool :: [Server] -> Keyspace -> IO CPool
- data CPool
- class MonadCatchIO m => MonadCassandra m
- data Cas a
- runCas :: CPool -> Cas a -> IO a
- data CassandraException
- = LocalProtocolError Text
- | AuthenticationException Text
- | ValueMarshallingException TransportDirection Text
- | ServerError Text
- | ProtocolError Text
- | BadCredentials Text
- | UnavailableException Text Consistency Int Int
- | Overloaded Text
- | IsBootstrapping Text
- | TruncateError Text
- | WriteTimeout Text Consistency Int Int Text
- | ReadTimeout Text Consistency Int Int Bool
- | SyntaxError Text
- | Unauthorized Text
- | Invalid Text
- | ConfigError Text
- | AlreadyExists Text Keyspace Table
- | Unprepared Text PreparedQueryID
- data TransportDirection
- newtype Keyspace = Keyspace Text
- data Result vs
- = Void
- | RowsResult Metadata [vs]
- | SetKeyspace Text
- | Prepared PreparedQueryID Metadata
- | SchemaChange Change Keyspace Table
- data TableSpec = TableSpec Keyspace Table
- data ColumnSpec = ColumnSpec TableSpec Text CType
- data Metadata = Metadata [ColumnSpec]
- data CType
- data Change
- newtype Table = Table Text
- data Consistency
- = ANY
- | ONE
- | TWO
- | THREE
- | QUORUM
- | ALL
- | LOCAL_QUORUM
- | EACH_QUORUM
- data Query
- query :: Text -> Query style i o
- data Style
- executeRows :: (MonadCassandra m, CasValues i, CasValues o) => Consistency -> Query Rows i o -> i -> m [o]
- executeRow :: (MonadCassandra m, CasValues i, CasValues o) => Consistency -> Query Rows i o -> i -> m (Maybe o)
- executeWrite :: (MonadCassandra m, CasValues i) => Consistency -> Query Write i () -> i -> m ()
- executeSchema :: (MonadCassandra m, CasValues i) => Consistency -> Query Schema i () -> i -> m (Change, Keyspace, Table)
- executeRaw :: (MonadCassandra m, CasValues i) => Query style any_i any_o -> i -> Consistency -> m (Result [ByteString])
- class CasType a where
- class CasValues v where
- encodeValues :: v -> [CType] -> Either CodingFailure [ByteString]
- decodeValues :: [(CType, ByteString)] -> Either CodingFailure v
- newtype Blob = Blob ByteString
- newtype Counter = Counter Int64
- data TimeUUID = TimeUUID UUID
- metadataTypes :: Metadata -> [CType]
Initialization
type Server = (HostName, ServiceName)Source
Monads
class MonadCatchIO m => MonadCassandra m Source
data CassandraException Source
Type used in operations
Void | |
RowsResult Metadata [vs] | |
SetKeyspace Text | |
Prepared PreparedQueryID Metadata | |
SchemaChange Change Keyspace Table |
data Consistency Source
Queries
Operations
executeRows :: (MonadCassandra m, CasValues i, CasValues o) => Consistency -> Query Rows i o -> i -> m [o]Source
Execute a query that returns rows
executeRow :: (MonadCassandra m, CasValues i, CasValues o) => Consistency -> Query Rows i o -> i -> m (Maybe o)Source
Helper for executeRows
useful in situations where you are only expecting one row
to be returned.
executeWrite :: (MonadCassandra m, CasValues i) => Consistency -> Query Write i () -> i -> m ()Source
Execute a write operation that returns void
executeSchema :: (MonadCassandra m, CasValues i) => Consistency -> Query Schema i () -> i -> m (Change, Keyspace, Table)Source
Execute a schema change, such as creating or dropping a table.
executeRaw :: (MonadCassandra m, CasValues i) => Query style any_i any_o -> i -> Consistency -> m (Result [ByteString])Source
Value types
CasType Bool | |
CasType Double | |
CasType Float | |
CasType Int | |
CasType Int64 | |
CasType Integer | |
CasType ByteString | |
CasType SockAddr | |
CasType Text | |
CasType UTCTime | |
CasType UUID | |
CasType TimeUUID | |
CasType Counter | |
CasType Blob | |
CasType a => CasType [a] | |
(CasType a, Ord a) => CasType (Set a) | |
(CasType a, Ord a, CasType b) => CasType (Map a b) |
encodeValues :: v -> [CType] -> Either CodingFailure [ByteString]Source
decodeValues :: [(CType, ByteString)] -> Either CodingFailure vSource
metadataTypes :: Metadata -> [CType]Source