Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Also retry IOExceptions in retryCas

  • Loading branch information...
commit e50f619c790394305edc9186d007d24372e8b5f4 1 parent 124f3a4
@ozataman ozataman authored
View
6 src/Database/Cassandra/Basic.hs
@@ -38,6 +38,8 @@ module Database.Cassandra.Basic
, R.RetrySettings (..)
, R.retrying
, retryCas
+ , casRetryH
+ , networkRetryH
-- * Filtering
, Selector(..)
@@ -384,10 +386,10 @@ throwing f = do
--
-- 'UnavailableException', 'TimedOutException' and
-- 'SchemaDisagreementException' will be automatically retried.
-retryCas :: (Functor m, MCIO.MonadCatchIO m)
+retryCas :: MCIO.MonadCatchIO m
=> R.RetrySettings
-- ^ For default settings, just use 'def'
-> m a
-- ^ Action to perform
-> m a
-retryCas set f = R.retrying set [shouldRetry] f
+retryCas set f = R.retrying set [casRetryH, networkRetryH] f
View
1  src/Database/Cassandra/Marshall.hs
@@ -69,6 +69,7 @@ module Database.Cassandra.Marshall
, R.RetrySettings (..)
, R.retrying
, CB.retryCas
+ , casRetryH
-- * Necessary Types
, ColumnName
View
4 src/Database/Cassandra/Retry.hs
@@ -49,7 +49,7 @@ instance Default RetrySettings where
-- | Retry ALL exceptions that may be raised. To be used with caution.
-retryAll :: (Functor m, MonadCatchIO m)
+retryAll :: MonadCatchIO m
=> RetrySettings
-> m a
-> m a
@@ -59,7 +59,7 @@ retryAll set f = retrying set [h] f
-- | A flexible action retrying combinator.
-retrying :: forall m a. (Functor m, MonadCatchIO m)
+retrying :: forall m a. MonadCatchIO m
=> RetrySettings
-- ^ For default settings, just use 'def'
-> [Handler m Bool]
View
16 src/Database/Cassandra/Types.hs
@@ -5,6 +5,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeSynonymInstances #-}
module Database.Cassandra.Types where
@@ -243,9 +244,11 @@ data CassandraException =
instance Exception CassandraException
-
-shouldRetry :: Monad m => MCIO.Handler m Bool
-shouldRetry = MCIO.Handler $ \ e -> return $
+-- | Exception handler that returns @True@ for errors that may be
+-- resolved after a retry. So they are good candidates for 'retrying'
+-- queries.
+casRetryH :: Monad m => MCIO.Handler m Bool
+casRetryH = MCIO.Handler $ \ e -> return $
case e of
UnavailableException{} -> True
TimedOutException{} -> True
@@ -253,6 +256,11 @@ shouldRetry = MCIO.Handler $ \ e -> return $
_ -> False
+-- | 'IOException's should be retried
+networkRetryH :: Monad m => MCIO.Handler m Bool
+networkRetryH = MCIO.Handler $ \ (_ :: IOException) -> return True
+
+
------------------------------------------------------------------------------
-- | Cassandra is VERY sensitive to its timestamp values. As a convention,
-- timestamps are always in microseconds
@@ -272,7 +280,7 @@ getTime = do
data PageResult m a
= PDone { pCache :: [a] }
-- ^ Done, this is all I have.
- | PMore { pCache :: [a], pMore :: (m (PageResult m a)) }
+ | PMore { pCache :: [a], pMore :: m (PageResult m a) }
-- ^ Here's a batch and there is more when you call the action.
Please sign in to comment.
Something went wrong with that request. Please try again.