cassandra-util-0.16.5: Cassandra Utilities
Safe HaskellSafe-Inferred
LanguageGHC2021

Cassandra.Exec

Description

This module exports components from Cassandra's Database.CQL.IO, adding a few functions we find useful, that are built on top of it.

Synopsis

Documentation

x5 :: RetrySettings Source #

x5 must only be used for idempotent queries, or for cases when a duplicate write has no severe consequences in the context of the application's data model. For more info see e.g. https://docs.datastax.com/en/developer/java-driver//3.6/manual/idempotence/

The eager retry policy permits 5 retries with exponential backoff (base-2) with an initial delay of 100ms, i.e. the retries will be performed with 100ms, 200ms, 400ms, 800ms and 1.6s delay, respectively, for a maximum delay of ~3s.

x1 :: RetrySettings Source #

Single, immediate retry, always safe. The defRetryHandlers used are safe also with non-idempotent queries.

paginateC :: (Tuple a, Tuple b, RunQ q, MonadClient m) => q R a b -> QueryParams a -> RetrySettings -> ConduitM () [b] m () Source #

Stream results of a query.

You can execute this conduit by doing transPipe (runClient ...).

data PageWithState a Source #

Constructors

PageWithState 

Instances

Instances details
Functor PageWithState Source # 
Instance details

Defined in Cassandra.Exec

Methods

fmap :: (a -> b) -> PageWithState a -> PageWithState b #

(<$) :: a -> PageWithState b -> PageWithState a #

paginateWithState :: (MonadClient m, Tuple a, Tuple b, RunQ q) => q R a b -> QueryParams a -> m (PageWithState b) Source #

Like paginate but exposes the paging state. This paging state can be serialised and sent to consumers of the API. The state is not good for long term storage as the bytestring format may change when the schema of a table changes or when cassandra is upgraded.

paginateWithStateC :: forall m a. Monad m => (Maybe PagingState -> m (PageWithState a)) -> ConduitT () [a] m () Source #

Like paginateWithState but returns a conduit instead of one page.

This can be used with paginateWithState like this: main :: IO () main = do runConduit $ paginateWithStateC getUsers .| mapC doSomethingWithAPageOfUsers where getUsers state = paginateWithState getUsersQuery (paramsPagingState Quorum () 10000 state)

data Row Source #

A row is a vector of Values.

Instances

Instances details
Show Row 
Instance details

Defined in Database.CQL.Protocol.Tuple

Methods

showsPrec :: Int -> Row -> ShowS #

show :: Row -> String #

showList :: [Row] -> ShowS #

PrivateTuple Row 
Instance details

Defined in Database.CQL.Protocol.Tuple

Tuple Row 
Instance details

Defined in Database.CQL.Protocol.Tuple

Eq Row 
Instance details

Defined in Database.CQL.Protocol.Tuple

Methods

(==) :: Row -> Row -> Bool #

(/=) :: Row -> Row -> Bool #

data PrepQuery k a b #

Instances

Instances details
RunQ PrepQuery 
Instance details

Defined in Database.CQL.IO

Methods

runQ :: (MonadClient m, Tuple a, Tuple b) => PrepQuery k a b -> QueryParams a -> m (HostResponse k a b) Source #

IsString (PrepQuery k a b) 
Instance details

Defined in Database.CQL.IO.PrepQuery

Methods

fromString :: String -> PrepQuery k a b #

data ClientState #

Instances

Instances details
MonadReader ClientState Client 
Instance details

Defined in Database.CQL.IO.Client

class (MonadIO m, MonadThrow m) => MonadClient (m :: Type -> Type) where #

Methods

liftClient :: Client a -> m a #

localState :: (ClientState -> ClientState) -> m a -> m a #

Instances

Instances details
MonadClient Client 
Instance details

Defined in Database.CQL.IO.Client

MonadClient m => MonadClient (ExceptT e m) 
Instance details

Defined in Database.CQL.IO.Client

Methods

liftClient :: Client a -> ExceptT e m a #

localState :: (ClientState -> ClientState) -> ExceptT e m a -> ExceptT e m a #

MonadClient m => MonadClient (ReaderT r m) 
Instance details

Defined in Database.CQL.IO.Client

Methods

liftClient :: Client a -> ReaderT r m a #

localState :: (ClientState -> ClientState) -> ReaderT r m a -> ReaderT r m a #

MonadClient m => MonadClient (StateT s m) 
Instance details

Defined in Database.CQL.IO.Client

Methods

liftClient :: Client a -> StateT s m a #

localState :: (ClientState -> ClientState) -> StateT s m a -> StateT s m a #

MonadClient m => MonadClient (StateT s m) 
Instance details

Defined in Database.CQL.IO.Client

Methods

liftClient :: Client a -> StateT s m a #

localState :: (ClientState -> ClientState) -> StateT s m a -> StateT s m a #

data Client a #

Instances

Instances details
MonadIO Client 
Instance details

Defined in Database.CQL.IO.Client

Methods

liftIO :: IO a -> Client a #

Applicative Client 
Instance details

Defined in Database.CQL.IO.Client

Methods

pure :: a -> Client a #

(<*>) :: Client (a -> b) -> Client a -> Client b #

liftA2 :: (a -> b -> c) -> Client a -> Client b -> Client c #

(*>) :: Client a -> Client b -> Client b #

(<*) :: Client a -> Client b -> Client a #

Functor Client 
Instance details

Defined in Database.CQL.IO.Client

Methods

fmap :: (a -> b) -> Client a -> Client b #

(<$) :: a -> Client b -> Client a #

Monad Client 
Instance details

Defined in Database.CQL.IO.Client

Methods

(>>=) :: Client a -> (a -> Client b) -> Client b #

(>>) :: Client a -> Client b -> Client b #

return :: a -> Client a #

MonadClient Client 
Instance details

Defined in Database.CQL.IO.Client

MonadCatch Client 
Instance details

Defined in Database.CQL.IO.Client

Methods

catch :: (HasCallStack, Exception e) => Client a -> (e -> Client a) -> Client a #

MonadMask Client 
Instance details

Defined in Database.CQL.IO.Client

Methods

mask :: HasCallStack => ((forall a. Client a -> Client a) -> Client b) -> Client b #

uninterruptibleMask :: HasCallStack => ((forall a. Client a -> Client a) -> Client b) -> Client b #

generalBracket :: HasCallStack => Client a -> (a -> ExitCase b -> Client c) -> (a -> Client b) -> Client (b, c) #

MonadThrow Client 
Instance details

Defined in Database.CQL.IO.Client

Methods

throwM :: (HasCallStack, Exception e) => e -> Client a #

MonadUnliftIO Client 
Instance details

Defined in Database.CQL.IO.Client

Methods

withRunInIO :: ((forall a. Client a -> IO a) -> IO b) -> Client b Source #

MonadReader ClientState Client 
Instance details

Defined in Database.CQL.IO.Client

data BatchM a #

Instances

Instances details
Applicative BatchM 
Instance details

Defined in Database.CQL.IO.Batch

Methods

pure :: a -> BatchM a #

(<*>) :: BatchM (a -> b) -> BatchM a -> BatchM b #

liftA2 :: (a -> b -> c) -> BatchM a -> BatchM b -> BatchM c #

(*>) :: BatchM a -> BatchM b -> BatchM b #

(<*) :: BatchM a -> BatchM b -> BatchM a #

Functor BatchM 
Instance details

Defined in Database.CQL.IO.Batch

Methods

fmap :: (a -> b) -> BatchM a -> BatchM b #

(<$) :: a -> BatchM b -> BatchM a #

Monad BatchM 
Instance details

Defined in Database.CQL.IO.Batch

Methods

(>>=) :: BatchM a -> (a -> BatchM b) -> BatchM b #

(>>) :: BatchM a -> BatchM b -> BatchM b #

return :: a -> BatchM a #

data Page a Source #

Return value of paginate. Contains the actual result values as well as an indication of whether there is more data available and the actual action to fetch the next page.

Constructors

Page 

Fields

Instances

Instances details
Functor Page 
Instance details

Defined in Database.CQL.IO

Methods

fmap :: (a -> b) -> Page a -> Page b #

(<$) :: a -> Page b -> Page a #

retry :: MonadClient m => RetrySettings -> m a -> m a #

write :: (MonadClient m, Tuple a, RunQ q) => q W a () -> QueryParams a -> m () Source #

Run a CQL write-only query (e.g. insert/update/delete), returning no result.

/Note: If the write operation is conditional, i.e. is in fact a "lightweight transaction" returning a result, trans must be used instead./

shutdown :: MonadIO m => ClientState -> m () #

trans :: (MonadClient m, Tuple a, RunQ q) => q W a Row -> QueryParams a -> m [Row] Source #

Run a CQL conditional write query (e.g. insert/update/delete) as a "lightweight transaction", returning the result Rows describing the outcome.

prepared :: QueryString k a b -> PrepQuery k a b #

runClient :: MonadIO m => ClientState -> Client a -> m a #

addQuery :: (Show a, Tuple a, Tuple b) => QueryString W a b -> a -> BatchM () #

addPrepQuery :: (Show a, Tuple a, Tuple b) => PrepQuery W a b -> a -> BatchM () #

query :: (MonadClient m, Tuple a, Tuple b, RunQ q) => q R a b -> QueryParams a -> m [b] Source #

Run a CQL read-only query returning a list of results.

query1 :: (MonadClient m, Tuple a, Tuple b, RunQ q) => q R a b -> QueryParams a -> m (Maybe b) Source #

Run a CQL read-only query returning a single result.

schema :: (MonadClient m, Tuple a, RunQ q) => q S a () -> QueryParams a -> m (Maybe SchemaChange) Source #

Run a CQL schema query, returning SchemaChange information, if any.

batch :: MonadClient m => BatchM () -> m () Source #

Run a batch query against a Cassandra node.

emptyPage :: Page a Source #

A page with an empty result list.

paginate :: (MonadClient m, Tuple a, Tuple b, RunQ q) => q R a b -> QueryParams a -> m (Page b) Source #

Run a CQL read-only query against a Cassandra node.

This function is like query, but limits the result size to 10000 (default) unless there is an explicit size restriction given in QueryParams. The returned Page can be used to continue the query.

Please note that -- as of Cassandra 2.1.0 -- if your requested page size is equal to the result size, hasMore might be true and a subsequent nextPage will return an empty list in result.