packages feed

cachix 0.8.0 → 0.8.1

raw patch · 4 files changed

+27/−6 lines, 4 files

Files

CHANGELOG.md view
@@ -7,6 +7,12 @@  ## Unreleased +## [0.8.1] - 2022-07-26++- Cachix Deploy: retry exceptions every 1s instead of exponentially ++### Fixed+ ## [0.8.0] - 2022-07-10  ### Fixed
cachix.cabal view
@@ -1,11 +1,11 @@ cabal-version:      2.2 name:               cachix-version: 0.8.0+version:            0.8.1 license:            Apache-2.0 license-file:       LICENSE copyright:          2018 Domen Kožar category:           Nix-maintainer:         domen@enlambda.com+maintainer:         domen@cachix.org author:             Domen Kožar homepage:           https://github.com/cachix/cachix#readme bug-reports:        https://github.com/cachix/cachix/issues@@ -153,7 +153,7 @@   import:             defaults   main-is:            Main.hs   build-tool-depends: hspec-discover:hspec-discover -any-  ghc-options:        -threaded -rtsopts -with-rtsopts=-maxN8+  ghc-options:        -g -threaded -rtsopts -with-rtsopts=-maxN8   hs-source-dirs:     cachix-deployment   other-modules:      Paths_cachix   autogen-modules:    Paths_cachix
src/Cachix/Client/Retry.hs view
@@ -4,11 +4,12 @@   ( retryAll,     retryAllWithLogging,     endlessRetryPolicy,+    endlessConstantRetryPolicy,   ) where  import Control.Exception.Safe (Handler (..), MonadMask, isSyncException)-import Control.Retry (RetryPolicy, RetryPolicyM, RetryStatus, exponentialBackoff, limitRetries, logRetries, recoverAll, recovering, skipAsyncExceptions)+import Control.Retry (RetryPolicy, RetryPolicyM, RetryStatus, constantDelay, exponentialBackoff, limitRetries, logRetries, recoverAll, recovering, skipAsyncExceptions) import Protolude hiding (Handler (..))  retryAll :: (MonadIO m, MonadMask m) => (RetryStatus -> m a) -> m a@@ -28,6 +29,10 @@ defaultRetryPolicy :: RetryPolicy defaultRetryPolicy =   exponentialBackoff (1000 * 1000) <> limitRetries 5++endlessConstantRetryPolicy :: RetryPolicy+endlessConstantRetryPolicy =+  constantDelay (1000 * 1000)  endlessRetryPolicy :: RetryPolicy endlessRetryPolicy =
src/Cachix/Deploy/Websocket.hs view
@@ -6,8 +6,10 @@ import Cachix.Client.Retry import Cachix.Client.Version (versionNumber) import qualified Cachix.Deploy.WebsocketPong as WebsocketPong+import Control.Retry (RetryStatus (..)) import Data.Aeson (FromJSON, ToJSON) import Data.IORef+import Data.String (String) import qualified Katip as K import Network.HTTP.Types (Header) import qualified Network.WebSockets as WS@@ -47,12 +49,14 @@         WebsocketPong.pingHandler pongState mainThreadID pongTimeout       connectionOptions = WebsocketPong.installPongHandler pongState WS.defaultConnectionOptions   runKatip $-    retryAllWithLogging endlessRetryPolicy (logger runKatip) $+    -- TODO: use exponential retry with reset: https://github.com/Soostone/retry/issues/25+    retryAllWithLogging endlessConstantRetryPolicy (logger runKatip) $       do         K.logLocM K.InfoS $ K.ls ("Agent " <> agentIdentifier <> " connecting to " <> toS (host options) <> toS (path options))         liftIO $ do           -- refresh pong state in case we're reconnecting           WebsocketPong.pongHandler pongState+          -- TODO: https://github.com/jaspervdj/websockets/issues/229           Wuss.runSecureClientWith (toS $ host options) 443 (toS $ path options) connectionOptions (headers options (toS agentToken)) $ \connection -> runKatip $ do             K.logLocM K.InfoS "Connected to Cachix Deploy service"             liftIO $@@ -74,7 +78,13 @@   ]  -- TODO: log the exception-logger runKatip _ exception _ = runKatip $ K.logLocM K.ErrorS $ K.ls $ "Retrying due to an exception:" <> displayException exception+logger runKatip _ exception retryStatus =+  runKatip $+    K.logLocM K.ErrorS $ K.ls $ "Retrying in " <> delay (rsPreviousDelay retryStatus) <> " due to an exception: " <> displayException exception+  where+    delay :: Maybe Int -> String+    delay Nothing = "0 seconds"+    delay (Just s) = show (floor (fromIntegral s / 1000 / 1000)) <> " seconds"  withKatip :: Bool -> (K.LogEnv -> IO a) -> IO a withKatip isVerbose =