Created
August 26, 2018 13:20
-
-
Save ethercrow/526e83eda39e7ccd81e44bbcb6ff9e53 to your computer and use it in GitHub Desktop.
Req config for flaky services (retry on everything >= 500)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Usage: | |
-- | |
-- import Network.HTTP.Flaky | |
-- | |
-- instance MonadHttp MyMonad where | |
-- handleHttpException = liftIO . throwIO | |
-- getHttpConfig = return flakyConfig | |
module Network.HTTP.Flaky | |
( flakyConfig | |
) where | |
import Debug.Trace | |
import Network.HTTP.Req | |
import Data.Default | |
import Network.HTTP.Client (responseStatus, Response) | |
import Network.HTTP.Types (statusCode) | |
flakyConfig :: HttpConfig | |
flakyConfig = def {httpConfigRetryJudge = judgeOfFlakiness} | |
judgeOfFlakiness :: _RetryStatus -> Response x -> Bool | |
judgeOfFlakiness _ _ | trace "judging" False = error "move along" | |
judgeOfFlakiness _ resp = statusCode (responseStatus resp) >= 500 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment