Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
This module exports types and functions from Database.CQL.IO, while adding a few wire specific functions.
Synopsis
- data ProtocolError where
- UnexpectedResponse :: forall k a b. Host -> Response k a b -> ProtocolError
- UnexpectedQueryId :: forall k a b. QueryId k a b -> ProtocolError
- UnsupportedCompression :: CompressionAlgorithm -> [CompressionAlgorithm] -> ProtocolError
- SerialiseError :: String -> ProtocolError
- ParseError :: String -> ProtocolError
- data S
- data R
- newtype Identity a = Identity {
- runIdentity :: a
- data W
- data Consistency
- = Any
- | One
- | LocalOne
- | Two
- | Three
- | Quorum
- | LocalQuorum
- | All
- | EachQuorum
- | Serial
- | LocalSerial
- newtype QueryString k a b = QueryString {}
- data Row
- data SerialConsistency
- data QueryParams a = QueryParams !Consistency !Bool a (Maybe Int32) (Maybe PagingState) (Maybe SerialConsistency) (Maybe Bool)
- newtype InetAddr = InetAddr {}
- data HostEvent
- data HostResponse k a b = HostResponse {
- hrHost :: !Host
- hrResponse :: !(Response k a b)
- data Host
- data Policy = Policy {}
- data Authenticator = Authenticator {
- authMechanism :: !AuthMechanism
- authOnRequest :: AuthContext -> IO (AuthResponse, s)
- authOnChallenge :: Maybe (s -> AuthChallenge -> IO (AuthResponse, s))
- authOnSuccess :: s -> AuthSuccess -> IO ()
- newtype AuthMechanism = AuthMechanism Text
- data AuthContext
- data ConnId
- newtype AuthPass = AuthPass Text
- newtype AuthUser = AuthUser Text
- data AuthenticationError
- data HashCollision = HashCollision !Text !Text
- data ConnectionError
- data HostError
- data ResponseError = ResponseError {}
- data LogLevel
- data Logger = Logger {
- logMessage :: LogLevel -> Builder -> IO ()
- logRequest :: ByteString -> IO ()
- logResponse :: ByteString -> IO ()
- data PrepQuery k a b
- data RetrySettings
- data PrepareStrategy
- data Settings
- data ClientState
- data DebugInfo = DebugInfo {
- policyInfo :: String
- jobInfo :: [InetAddr]
- hostInfo :: [Host]
- controlInfo :: (Host, ControlState)
- class (MonadIO m, MonadThrow m) => MonadClient (m :: Type -> Type) where
- liftClient :: Client a -> m a
- localState :: (ClientState -> ClientState) -> m a -> m a
- data Client a
- data BatchM a
- data Page a = Page {}
- class RunQ (q :: Type -> Type -> Type -> Type) where
- runQ :: (MonadClient m, Tuple a, Tuple b) => q k a b -> QueryParams a -> m (HostResponse k a b)
- random :: IO Policy
- retry :: MonadClient m => RetrySettings -> m a -> m a
- write :: (MonadClient m, Tuple a, RunQ q) => q W a () -> QueryParams a -> m ()
- shutdown :: MonadIO m => ClientState -> m ()
- once :: MonadClient m => m a -> m a
- init :: MonadIO m => Settings -> m ClientState
- trans :: (MonadClient m, Tuple a, RunQ q) => q W a Row -> QueryParams a -> m [Row]
- fromRow :: Cql a => Int -> Row -> Either String a
- hostAddr :: Lens' Host InetAddr
- dataCentre :: Lens' Host Text
- rack :: Lens' Host Text
- roundRobin :: IO Policy
- authConnId :: Lens' AuthContext ConnId
- authHost :: Lens' AuthContext InetAddr
- passwordAuthenticator :: AuthUser -> AuthPass -> Authenticator
- nullLogger :: Logger
- stdoutLogger :: LogLevel -> Logger
- prepared :: QueryString k a b -> PrepQuery k a b
- queryString :: PrepQuery k a b -> QueryString k a b
- defQueryParams :: Consistency -> a -> QueryParams a
- defSettings :: Settings
- setProtocolVersion :: Version -> Settings -> Settings
- setContacts :: String -> [String] -> Settings -> Settings
- addContact :: String -> Settings -> Settings
- setPortNumber :: PortNumber -> Settings -> Settings
- setPolicy :: IO Policy -> Settings -> Settings
- setPrepareStrategy :: PrepareStrategy -> Settings -> Settings
- setLogger :: Logger -> Settings -> Settings
- setIdleTimeout :: NominalDiffTime -> Settings -> Settings
- setMaxConnections :: Int -> Settings -> Settings
- setPoolStripes :: Int -> Settings -> Settings
- setMaxTimeouts :: Int -> Settings -> Settings
- setCompression :: Compression -> Settings -> Settings
- setMaxStreams :: Int -> Settings -> Settings
- setConnectTimeout :: NominalDiffTime -> Settings -> Settings
- setSendTimeout :: NominalDiffTime -> Settings -> Settings
- setResponseTimeout :: NominalDiffTime -> Settings -> Settings
- setKeyspace :: Keyspace -> Settings -> Settings
- setRetrySettings :: RetrySettings -> Settings -> Settings
- setMaxRecvBuffer :: Int -> Settings -> Settings
- setSSLContext :: SSLContext -> Settings -> Settings
- setAuthentication :: [Authenticator] -> Settings -> Settings
- noRetry :: RetrySettings
- defRetrySettings :: RetrySettings
- eagerRetrySettings :: RetrySettings
- defRetryPolicy :: RetryPolicy
- eagerRetryPolicy :: RetryPolicy
- defRetryHandlers :: forall (m :: Type -> Type). Monad m => [RetryStatus -> Handler m Bool]
- eagerRetryHandlers :: forall (m :: Type -> Type). Monad m => [RetryStatus -> Handler m Bool]
- setRetryPolicy :: RetryPolicy -> RetrySettings -> RetrySettings
- setRetryHandlers :: (forall (m :: Type -> Type). Monad m => [RetryStatus -> Handler m Bool]) -> RetrySettings -> RetrySettings
- adjustConsistency :: Consistency -> RetrySettings -> RetrySettings
- adjustSendTimeout :: NominalDiffTime -> RetrySettings -> RetrySettings
- adjustResponseTimeout :: NominalDiffTime -> RetrySettings -> RetrySettings
- runClient :: MonadIO m => ClientState -> Client a -> m a
- request :: (MonadClient m, Tuple a, Tuple b) => Request k a b -> m (HostResponse k a b)
- debugInfo :: MonadClient m => m DebugInfo
- getResult :: MonadThrow m => HostResponse k a b -> m (Result k a b)
- 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 ()
- setType :: BatchType -> BatchM ()
- setConsistency :: Consistency -> BatchM ()
- setSerialConsistency :: SerialConsistency -> BatchM ()
- query :: (MonadClient m, Tuple a, Tuple b, RunQ q) => q R a b -> QueryParams a -> m [b]
- query1 :: (MonadClient m, Tuple a, Tuple b, RunQ q) => q R a b -> QueryParams a -> m (Maybe b)
- schema :: (MonadClient m, Tuple a, RunQ q) => q S a () -> QueryParams a -> m (Maybe SchemaChange)
- batch :: MonadClient m => BatchM () -> m ()
- emptyPage :: Page a
- paginate :: (MonadClient m, Tuple a, Tuple b, RunQ q) => q R a b -> QueryParams a -> m (Page b)
- mkLogger :: Logger -> Logger
- initialContactsDisco :: MonadIO m => String -> String -> m (NonEmpty String)
- initialContactsPlain :: MonadIO m => Text -> m (NonEmpty String)
- dcAwareRandomPolicy :: Text -> IO Policy
- dcFilterPolicyIfConfigured :: Logger -> Maybe Text -> IO Policy
Documentation
data ProtocolError where #
UnexpectedResponse :: forall k a b. Host -> Response k a b -> ProtocolError | |
UnexpectedQueryId :: forall k a b. QueryId k a b -> ProtocolError | |
UnsupportedCompression :: CompressionAlgorithm -> [CompressionAlgorithm] -> ProtocolError | |
SerialiseError :: String -> ProtocolError | |
ParseError :: String -> ProtocolError |
Instances
Exception ProtocolError | |
Defined in Database.CQL.IO.Exception | |
Show ProtocolError | |
Defined in Database.CQL.IO.Exception showsPrec :: Int -> ProtocolError -> ShowS # show :: ProtocolError -> String # showList :: [ProtocolError] -> ShowS # |
Identity functor and monad. (a non-strict monad)
Since: base-4.8.0.0
Identity | |
|
Instances
data Consistency Source #
Consistency level.
See: Consistency
Any | |
One | |
LocalOne | |
Two | |
Three | |
Quorum | |
LocalQuorum | |
All | |
EachQuorum | Only for write queries. |
Serial | Only for read queries. |
LocalSerial | Only for read queries. |
Instances
Show Consistency | |
Defined in Database.CQL.Protocol.Types showsPrec :: Int -> Consistency -> ShowS # show :: Consistency -> String # showList :: [Consistency] -> ShowS # | |
Eq Consistency | |
Defined in Database.CQL.Protocol.Types (==) :: Consistency -> Consistency -> Bool # (/=) :: Consistency -> Consistency -> Bool # |
newtype QueryString k a b Source #
Instances
RunQ QueryString | |
Defined in Database.CQL.IO runQ :: (MonadClient m, Tuple a, Tuple b) => QueryString k a b -> QueryParams a -> m (HostResponse k a b) Source # | |
IsString (QueryString k a b) | |
Defined in Database.CQL.Protocol.Types fromString :: String -> QueryString k a b # | |
Show (QueryString k a b) | |
Defined in Database.CQL.Protocol.Types showsPrec :: Int -> QueryString k a b -> ShowS # show :: QueryString k a b -> String # showList :: [QueryString k a b] -> ShowS # | |
Eq (QueryString k a b) | |
Defined in Database.CQL.Protocol.Types (==) :: QueryString k a b -> QueryString k a b -> Bool # (/=) :: QueryString k a b -> QueryString k a b -> Bool # |
A row is a vector of Value
s.
data SerialConsistency Source #
Consistency level for the serial phase of conditional updates (aka "lightweight transactions").
See: SerialConsistency
SerialConsistency | Default. Quorum-based linearizable consistency. |
LocalSerialConsistency | Like |
Instances
Show SerialConsistency | |
Defined in Database.CQL.Protocol.Request showsPrec :: Int -> SerialConsistency -> ShowS # show :: SerialConsistency -> String # showList :: [SerialConsistency] -> ShowS # |
data QueryParams a Source #
Query parameters.
QueryParams !Consistency !Bool a (Maybe Int32) (Maybe PagingState) (Maybe SerialConsistency) (Maybe Bool) |
Instances
Show a => Show (QueryParams a) | |
Defined in Database.CQL.Protocol.Request showsPrec :: Int -> QueryParams a -> ShowS # show :: QueryParams a -> String # showList :: [QueryParams a] -> ShowS # |
data HostResponse k a b #
HostResponse | |
|
Instances
Show b => Show (HostResponse k a b) | |
Defined in Database.CQL.IO.Cluster.Host showsPrec :: Int -> HostResponse k a b -> ShowS # show :: HostResponse k a b -> String # showList :: [HostResponse k a b] -> ShowS # |
data Authenticator #
Authenticator | |
|
newtype AuthMechanism #
Instances
data AuthContext #
data AuthenticationError #
AuthenticationRequired !AuthMechanism | |
UnexpectedAuthenticationChallenge !AuthMechanism !AuthChallenge |
Instances
Exception AuthenticationError | |
Show AuthenticationError | |
Defined in Database.CQL.IO.Exception showsPrec :: Int -> AuthenticationError -> ShowS # show :: AuthenticationError -> String # showList :: [AuthenticationError] -> ShowS # |
data HashCollision #
Instances
Exception HashCollision | |
Defined in Database.CQL.IO.Exception | |
Show HashCollision | |
Defined in Database.CQL.IO.Exception showsPrec :: Int -> HashCollision -> ShowS # show :: HashCollision -> String # showList :: [HashCollision] -> ShowS # |
data ConnectionError #
Instances
Exception ConnectionError | |
Defined in Database.CQL.IO.Exception | |
Show ConnectionError | |
Defined in Database.CQL.IO.Exception showsPrec :: Int -> ConnectionError -> ShowS # show :: ConnectionError -> String # showList :: [ConnectionError] -> ShowS # |
Instances
Exception HostError | |
Defined in Database.CQL.IO.Exception toException :: HostError -> SomeException # fromException :: SomeException -> Maybe HostError # displayException :: HostError -> String # | |
Show HostError | |
data ResponseError #
Instances
Exception ResponseError | |
Defined in Database.CQL.IO.Exception | |
Show ResponseError | |
Defined in Database.CQL.IO.Exception showsPrec :: Int -> ResponseError -> ShowS # show :: ResponseError -> String # showList :: [ResponseError] -> ShowS # |
Logger | |
|
Instances
RunQ PrepQuery | |
Defined in Database.CQL.IO runQ :: (MonadClient m, Tuple a, Tuple b) => PrepQuery k a b -> QueryParams a -> m (HostResponse k a b) Source # | |
IsString (PrepQuery k a b) | |
Defined in Database.CQL.IO.PrepQuery fromString :: String -> PrepQuery k a b # |
data RetrySettings #
data PrepareStrategy #
Instances
Show PrepareStrategy | |
Defined in Database.CQL.IO.Settings showsPrec :: Int -> PrepareStrategy -> ShowS # show :: PrepareStrategy -> String # showList :: [PrepareStrategy] -> ShowS # | |
Eq PrepareStrategy | |
Defined in Database.CQL.IO.Settings (==) :: PrepareStrategy -> PrepareStrategy -> Bool # (/=) :: PrepareStrategy -> PrepareStrategy -> Bool # | |
Ord PrepareStrategy | |
Defined in Database.CQL.IO.Settings compare :: PrepareStrategy -> PrepareStrategy -> Ordering # (<) :: PrepareStrategy -> PrepareStrategy -> Bool # (<=) :: PrepareStrategy -> PrepareStrategy -> Bool # (>) :: PrepareStrategy -> PrepareStrategy -> Bool # (>=) :: PrepareStrategy -> PrepareStrategy -> Bool # max :: PrepareStrategy -> PrepareStrategy -> PrepareStrategy # min :: PrepareStrategy -> PrepareStrategy -> PrepareStrategy # |
data ClientState #
Instances
MonadReader ClientState Client | |
Defined in Database.CQL.IO.Client ask :: Client ClientState # local :: (ClientState -> ClientState) -> Client a -> Client a # reader :: (ClientState -> a) -> Client a # |
DebugInfo | |
|
class (MonadIO m, MonadThrow m) => MonadClient (m :: Type -> Type) where #
liftClient :: Client a -> m a #
localState :: (ClientState -> ClientState) -> m a -> m a #
Instances
MonadClient Client | |
Defined in Database.CQL.IO.Client liftClient :: Client a -> Client a # localState :: (ClientState -> ClientState) -> Client a -> Client a # | |
MonadClient m => MonadClient (ExceptT e m) | |
Defined in Database.CQL.IO.Client liftClient :: Client a -> ExceptT e m a # localState :: (ClientState -> ClientState) -> ExceptT e m a -> ExceptT e m a # | |
MonadClient m => MonadClient (ReaderT r m) | |
Defined in Database.CQL.IO.Client liftClient :: Client a -> ReaderT r m a # localState :: (ClientState -> ClientState) -> ReaderT r m a -> ReaderT r m a # | |
MonadClient m => MonadClient (StateT s m) | |
Defined in Database.CQL.IO.Client liftClient :: Client a -> StateT s m a # localState :: (ClientState -> ClientState) -> StateT s m a -> StateT s m a # | |
MonadClient m => MonadClient (StateT s m) | |
Defined in Database.CQL.IO.Client liftClient :: Client a -> StateT s m a # localState :: (ClientState -> ClientState) -> StateT s m a -> StateT s m a # |
Instances
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.
class RunQ (q :: Type -> Type -> Type -> Type) where Source #
A type which can be run as a query.
runQ :: (MonadClient m, Tuple a, Tuple b) => q k a b -> QueryParams a -> m (HostResponse k a b) Source #
Instances
RunQ QueryString | |
Defined in Database.CQL.IO runQ :: (MonadClient m, Tuple a, Tuple b) => QueryString k a b -> QueryParams a -> m (HostResponse k a b) Source # | |
RunQ PrepQuery | |
Defined in Database.CQL.IO runQ :: (MonadClient m, Tuple a, Tuple b) => PrepQuery k a b -> QueryParams a -> m (HostResponse k a b) Source # |
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 () #
once :: MonadClient m => m a -> m a #
init :: MonadIO m => Settings -> m ClientState #
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 Row
s describing the
outcome.
dataCentre :: Lens' Host Text #
roundRobin :: IO Policy #
passwordAuthenticator :: AuthUser -> AuthPass -> Authenticator #
nullLogger :: Logger #
stdoutLogger :: LogLevel -> Logger #
prepared :: QueryString k a b -> PrepQuery k a b #
queryString :: PrepQuery k a b -> QueryString k a b #
defQueryParams :: Consistency -> a -> QueryParams a #
defSettings :: Settings #
setProtocolVersion :: Version -> Settings -> Settings #
addContact :: String -> Settings -> Settings #
setPortNumber :: PortNumber -> Settings -> Settings #
setPrepareStrategy :: PrepareStrategy -> Settings -> Settings #
setIdleTimeout :: NominalDiffTime -> Settings -> Settings #
setMaxConnections :: Int -> Settings -> Settings #
setPoolStripes :: Int -> Settings -> Settings #
setMaxTimeouts :: Int -> Settings -> Settings #
setCompression :: Compression -> Settings -> Settings #
setMaxStreams :: Int -> Settings -> Settings #
setConnectTimeout :: NominalDiffTime -> Settings -> Settings #
setSendTimeout :: NominalDiffTime -> Settings -> Settings #
setResponseTimeout :: NominalDiffTime -> Settings -> Settings #
setKeyspace :: Keyspace -> Settings -> Settings #
setRetrySettings :: RetrySettings -> Settings -> Settings #
setMaxRecvBuffer :: Int -> Settings -> Settings #
setSSLContext :: SSLContext -> Settings -> Settings #
setAuthentication :: [Authenticator] -> Settings -> Settings #
defRetryHandlers :: forall (m :: Type -> Type). Monad m => [RetryStatus -> Handler m Bool] #
eagerRetryHandlers :: forall (m :: Type -> Type). Monad m => [RetryStatus -> Handler m Bool] #
setRetryPolicy :: RetryPolicy -> RetrySettings -> RetrySettings #
setRetryHandlers :: (forall (m :: Type -> Type). Monad m => [RetryStatus -> Handler m Bool]) -> RetrySettings -> RetrySettings #
runClient :: MonadIO m => ClientState -> Client a -> m a #
request :: (MonadClient m, Tuple a, Tuple b) => Request k a b -> m (HostResponse k a b) #
debugInfo :: MonadClient m => m DebugInfo #
getResult :: MonadThrow m => HostResponse k a b -> m (Result k a b) #
setConsistency :: Consistency -> BatchM () #
setSerialConsistency :: SerialConsistency -> 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.
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
.
initialContactsDisco :: MonadIO m => String -> String -> m (NonEmpty String) Source #
This function is likely only useful at Wire, as it is Wire-infra specific. Given a server name and a url returning a wire-custom "disco" json (AWS describe-instances-like json), e.g. { "roles" : { "server_name": [ {"privateIpAddress": "...", ...}, {...} ] } }, return a list of IP addresses.
initialContactsPlain :: MonadIO m => Text -> m (NonEmpty String) Source #
Puts the address into a list using the same signature as the other initialContacts