packages feed

retry 0.7.4.2 → 0.7.4.3

raw patch · 4 files changed

+30/−9 lines, 4 filesdep ~HUnitdep ~QuickCheck

Dependency ranges changed: HUnit, QuickCheck

Files

README.md view
@@ -33,4 +33,5 @@ - John Wiegley - Michael Snoyman - Michael Xavier+- Marco Zocca (@ocramz) 
changelog.md view
@@ -1,3 +1,9 @@+0.7.4.3+* Loosen dependency upper bounds.++0.7.5+* Add skipAsyncExceptions helper function+ 0.7.4.2 * Loosen HUnit dependency for tests. 
retry.cabal view
@@ -14,7 +14,7 @@         case we should hang back for a bit and retry the query instead         of simply raising an exception. -version:             0.7.4.2+version:             0.7.4.3 synopsis:            Retry combinators for monadic actions that may fail license:             BSD3 license-file:        LICENSE@@ -54,8 +54,8 @@       , data-default-class       , random       , time-      , QuickCheck         >= 2.7 && < 2.10-      , HUnit              >= 1.2.5.2 && < 1.6+      , QuickCheck         >= 2.7 && < 2.11+      , HUnit              >= 1.2.5.2 && < 1.7       , hspec              >= 1.9       , stm       , ghc-prim
src/Control/Retry.hs view
@@ -51,6 +51,7 @@     , recovering     , stepping     , recoverAll+    , skipAsyncExceptions     , logRetries     , defaultLogMsg @@ -294,7 +295,7 @@ -- -- temp = min(cap, base * 2 ** attempt) ----- sleep = temp / 2 + random_between(0, temp / 2)+-- sleep = temp \/ 2 + random_between(0, temp \/ 2) fullJitterBackoff :: MonadIO m => Int -> RetryPolicyM m fullJitterBackoff base = RetryPolicyM $ \ RetryStatus { rsIterNumber = n } -> do   let d = (base `boundedMult` boundedPow 2 n) `div` 2@@ -408,14 +409,27 @@          -> m a recoverAll set f = recovering set handlers f     where+      handlers = skipAsyncExceptions ++ [h]+      h _ = Handler $ \ (_ :: SomeException) -> return True+++-------------------------------------------------------------------------------+-- | List of pre-made handlers that will skip retries on+-- 'AsyncException' and 'SomeAsyncException'. Append your handlers to+-- this list as a convenient way to make sure you're not catching+-- async exceptions like user interrupt.+skipAsyncExceptions +    :: (MonadIO m, MonadMask m) +    => [RetryStatus -> Handler m Bool]+skipAsyncExceptions = handlers+  where+    asyncH _ = Handler $ \ (_ :: AsyncException) -> return False #if MIN_VERSION_base(4, 7, 0)-      someAsyncH _ = Handler $ \(_ :: SomeAsyncException) -> return False-      handlers = [asyncH, someAsyncH, h]+    someAsyncH _ = Handler $ \(_ :: SomeAsyncException) -> return False+    handlers = [asyncH, someAsyncH] #else-      handlers = [asyncH, h]+    handlers = [asyncH] #endif-      asyncH _ = Handler $ \ (_ :: AsyncException) -> return False-      h _ = Handler $ \ (_ :: SomeException) -> return True   -------------------------------------------------------------------------------