wolf 0.3.8 → 0.3.9
raw patch · 2 files changed
+17/−2 lines, 2 files
Files
- src/Network/AWS/Wolf/Ctx.hs +16/−1
- wolf.cabal +1/−1
src/Network/AWS/Wolf/Ctx.hs view
@@ -17,11 +17,13 @@ , preAmazonDecisionCtx ) where +import Control.Concurrent import Control.Monad.Trans.AWS import Data.Aeson import Network.AWS.SWF import Network.AWS.Wolf.Prelude import Network.AWS.Wolf.Types+import Network.HTTP.Types -- | Handler for exceptions, traces and rethrows. --@@ -80,13 +82,26 @@ c <- view amazonStoreCtx <&> cPreamble <>~ preamble runTransT c $ catch action catcher +-- | Amazon throttle handler.+--+throttler :: MonadAmazon c m => m a -> Error -> m a+throttler action e =+ case e of+ ServiceError se -> do+ let delay = liftIO $ threadDelay $ 5 * 1000000+ bool (throwIO e) (delay >> (catch action $ throttler action)) $+ se ^. serviceStatus == badRequest400 &&+ se ^. serviceCode == "Throttling"+ _ ->+ throwIO e+ -- | Run amazon work context. -- runAmazonWorkCtx :: MonadAmazon c m => Text -> TransT AmazonWorkCtx m a -> m a runAmazonWorkCtx queue action = do let preamble = [ "queue" .= queue ] c <- view amazonCtx <&> cPreamble <>~ preamble- runTransT (AmazonWorkCtx c queue) $ catch action catcher+ runTransT (AmazonWorkCtx c queue) $ catch (catch action $ throttler action) catcher -- | Update amazon context's preamble. --
wolf.cabal view
@@ -1,5 +1,5 @@ name: wolf-version: 0.3.8+version: 0.3.9 synopsis: Amazon Simple Workflow Service Wrapper. description: Wolf is a wrapper around Amazon Simple Workflow Service. homepage: https://github.com/swift-nav/wolf