Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Settings = Settings {}
- data PrepareStrategy
- data RetrySettings = RetrySettings {
- _retryPolicy :: forall m. Monad m => RetryPolicyM m
- _reducedConsistency :: Maybe Consistency
- _sendTimeoutChange :: Milliseconds
- _recvTimeoutChange :: Milliseconds
- _retryHandlers :: forall m. Monad m => [RetryStatus -> Handler m Bool]
- sendTimeoutChange :: Lens' RetrySettings Milliseconds
- retryPolicy :: forall m. Monad m => Getter RetrySettings (RetryPolicyM m)
- retryHandlers :: forall m. Monad m => Getter RetrySettings [RetryStatus -> Handler m Bool]
- reducedConsistency :: Lens' RetrySettings (Maybe Consistency)
- recvTimeoutChange :: Lens' RetrySettings Milliseconds
- retrySettings :: Lens' Settings RetrySettings
- protoVersion :: Lens' Settings Version
- prepStrategy :: Lens' Settings PrepareStrategy
- portnumber :: Lens' Settings PortNumber
- poolSettings :: Lens' Settings PoolSettings
- policyMaker :: Lens' Settings (IO Policy)
- logger :: Lens' Settings Logger
- contacts :: Lens' Settings (NonEmpty String)
- connSettings :: Lens' Settings ConnectionSettings
- 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 :: Monad m => [RetryStatus -> Handler m Bool]
- eagerRetryHandlers :: Monad m => [RetryStatus -> Handler m Bool]
- setRetryPolicy :: RetryPolicy -> RetrySettings -> RetrySettings
- setRetryHandlers :: (forall m. Monad m => [RetryStatus -> Handler m Bool]) -> RetrySettings -> RetrySettings
- adjustConsistency :: Consistency -> RetrySettings -> RetrySettings
- adjustSendTimeout :: NominalDiffTime -> RetrySettings -> RetrySettings
- adjustResponseTimeout :: NominalDiffTime -> RetrySettings -> RetrySettings
Documentation
data PrepareStrategy Source #
Strategy for the execution of PrepQuery
s.
EagerPrepare | cluster-wide preparation |
LazyPrepare | on-demand per node preparation |
Instances
Eq PrepareStrategy Source # | |
Defined in Database.CQL.IO.Settings (==) :: PrepareStrategy -> PrepareStrategy -> Bool # (/=) :: PrepareStrategy -> PrepareStrategy -> Bool # | |
Ord PrepareStrategy Source # | |
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 # | |
Show PrepareStrategy Source # | |
Defined in Database.CQL.IO.Settings showsPrec :: Int -> PrepareStrategy -> ShowS # show :: PrepareStrategy -> String # showList :: [PrepareStrategy] -> ShowS # |
data RetrySettings Source #
Retry settings control if and how retries are performed by the client upon encountering errors during query execution.
There are three aspects to the retry settings:
- What to retry. Determined by the retry handlers (
setRetryHandlers
). - How to perform the retries. Determined by the retry policy
(
setRetryPolicy
). - Configuration adjustments to be performed before retrying. Determined by
adjustConsistency
,adjustSendTimeout
andadjustResponseTimeout
. These adjustments are performed once before the first retry and are scoped to the retries only.
Retry settings can be scoped to a client action by retry
,
thus locally overriding the "global" retry settings configured by
setRetrySettings
.
RetrySettings | |
|
retryPolicy :: forall m. Monad m => Getter RetrySettings (RetryPolicyM m) Source #
retryHandlers :: forall m. Monad m => Getter RetrySettings [RetryStatus -> Handler m Bool] Source #
defSettings :: Settings Source #
Default settings:
- The initial contact point is "localhost" on port 9042.
- The load-balancing policy is
random
. - The binary protocol version is 3.
- The connection idle timeout is 60s.
- The connection pool uses 4 stripes to mitigate thread contention.
- Connections use a connect timeout of 5s, a send timeout of 3s and a receive timeout of 10s.
- 128 streams per connection are used.
- 16k receive buffer size.
- No compression is applied to frame bodies.
- No default keyspace is used.
- A single, immediate retry is performed for errors that are always safe to
retry and are known to have good chances of succeeding on a retry.
See
defRetrySettings
. - Query preparation is done lazily. See
PrepareStrategy
.
setProtocolVersion :: Version -> Settings -> Settings Source #
Set the binary protocol version to use.
setContacts :: String -> [String] -> Settings -> Settings Source #
Set the initial contact points (hosts) from which node discovery will start.
setPortNumber :: PortNumber -> Settings -> Settings Source #
Set the portnumber to use to connect on every node of the cluster.
setPrepareStrategy :: PrepareStrategy -> Settings -> Settings Source #
Set strategy to use for preparing statements.
setLogger :: Logger -> Settings -> Settings Source #
Set the Logger
to use for processing log messages emitted by the client.
setIdleTimeout :: NominalDiffTime -> Settings -> Settings Source #
Set the connection idle timeout. Connections in a pool will be closed if not in use for longer than this timeout.
setPoolStripes :: Int -> Settings -> Settings Source #
Set the number of pool stripes to use. A good setting is equal to the number of CPU cores this codes is running on.
setMaxTimeouts :: Int -> Settings -> Settings Source #
When receiving a response times out, we can no longer use the stream of the connection that was used to make the request as it is uncertain if a response will arrive later. Thus the bandwith of a connection will be decreased. This settings defines a threshold after which we close the connection to get a new one with all streams available.
setCompression :: Compression -> Settings -> Settings Source #
Set the compression to use for frame body compression.
setMaxStreams :: Int -> Settings -> Settings Source #
Set the maximum number of streams per connection. In version 2 of the binary protocol at most 128 streams can be used. Version 3 supports up to 32768 streams.
setConnectTimeout :: NominalDiffTime -> Settings -> Settings Source #
Set the connect timeout of a connection.
setSendTimeout :: NominalDiffTime -> Settings -> Settings Source #
Set the send timeout of a connection. Requests exceeding the send
timeout will cause the connection to be closed and fail with a
ConnectionClosed
exception.
setResponseTimeout :: NominalDiffTime -> Settings -> Settings Source #
Set the response timeout of a connection. Requests exceeding the
response timeout will fail with a ResponseTimeout
exception.
setKeyspace :: Keyspace -> Settings -> Settings Source #
Set the default keyspace to use. Every new connection will be initialised to use this keyspace.
setRetrySettings :: RetrySettings -> Settings -> Settings Source #
Set the retry settings to use.
setMaxRecvBuffer :: Int -> Settings -> Settings Source #
Set maximum receive buffer size.
The actual buffer size used will be the minimum of the CQL response size and the value set here.
setSSLContext :: SSLContext -> Settings -> Settings Source #
Set a fully configured SSL context.
This will make client server queries use TLS.
setAuthentication :: [Authenticator] -> Settings -> Settings Source #
Set the supported authentication mechanisms.
When a Cassandra server requests authentication on a connection,
it specifies the requested AuthMechanism
. The client Authenticator
is chosen based that name. If no authenticator with a matching
name is configured, an AuthenticationError
is thrown.
noRetry :: RetrySettings Source #
Never retry.
defRetrySettings :: RetrySettings Source #
Default retry settings, combining defRetryHandlers
with defRetryPolicy
.
Consistency is never reduced on retries and timeout values remain unchanged.
eagerRetrySettings :: RetrySettings Source #
Eager retry settings, combining eagerRetryHandlers
with
eagerRetryPolicy
. Consistency is never reduced on retries and timeout
values remain unchanged.
defRetryPolicy :: RetryPolicy Source #
The default retry policy permits a single, immediate retry.
eagerRetryPolicy :: RetryPolicy Source #
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.
defRetryHandlers :: Monad m => [RetryStatus -> Handler m Bool] Source #
The default retry handlers permit a retry for the following errors:
- A
HostError
, since it always occurs before a query has been sent to the server. - A
ConnectionError
that is aConnectTimeout
, since it always occurs before a query has been sent to the server. A
ResponseError
that is one of the following:Unavailable
, since that is an error response from a coordinator before the query is actually executed.- A
ReadTimeout
that indicates that the required consistency level could be achieved but the data was unfortunately chosen by the coordinator to be returned from a replica that turned out to be unavailable. A retry has a good chance of getting the data from one of the other replicas. - A
WriteTimeout
for a write to the batch log failed. The batch log is written prior to execution of the statements of the batch and hence these errors are safe to retry.
eagerRetryHandlers :: Monad m => [RetryStatus -> Handler m Bool] Source #
The eager retry handlers permit a superset of the errors
of defRetryHandlers
, namely:
- Any
ResponseError
that is aReadTimeout
,WriteTimeout
,Overloaded
,Unavailable
orServerError
. - Any
ConnectionError
. - Any
IOException
. - Any
HostError
. - Any
SomeSSLException
(if an SSL context is configured).
Notably, these retry handlers are only safe to use for idempotent queries, or if a duplicate write has no severe consequences in the context of the application's data model.
setRetryPolicy :: RetryPolicy -> RetrySettings -> RetrySettings Source #
Set the RetryPolicy
to apply on retryable exceptions,
which determines the number and distribution of retries over time,
i.e. how retries are performed. Configuring a retry policy
does not specify what errors should actually be retried.
See setRetryHandlers
.
setRetryHandlers :: (forall m. Monad m => [RetryStatus -> Handler m Bool]) -> RetrySettings -> RetrySettings Source #
Set the exception handlers that decide whether a request can be
retried by the client, i.e. what errors are permissible to retry.
For configuring how the retries are performed, see setRetryPolicy
.
adjustConsistency :: Consistency -> RetrySettings -> RetrySettings Source #
On retry, change the consistency to the given value.
adjustSendTimeout :: NominalDiffTime -> RetrySettings -> RetrySettings Source #
On retry adjust the send timeout. See setSendTimeout
.
adjustResponseTimeout :: NominalDiffTime -> RetrySettings -> RetrySettings Source #
On retry adjust the response timeout. See setResponseTimeout
.