packages feed

conferer-hedis 0.3.0.0 → 0.4.0.0

raw patch · 3 files changed

+23/−9 lines, 3 filesdep ~confererPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: conferer

API changes (from Hackage documentation)

Files

conferer-hedis.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.18 --- This file has been generated from package.yaml by hpack version 0.31.2.+-- This file has been generated from package.yaml by hpack version 0.33.0. -- -- see: https://github.com/sol/hpack ----- hash: 38ac739d423c0e28c7b8dd4d614f1092cbebb6371eef9f2dd9fa21f0c5c618a1+-- hash: 6345ad1aaee5cd66b5e03045b64616ce78b7acacf039832f7468a96125a7d17e  name:           conferer-hedis-version:        0.3.0.0+version:        0.4.0.0 synopsis:       conferer's FromConfig instances for hedis settings  description:    Library to abstract the parsing of many haskell config values from different config sources@@ -33,7 +33,7 @@   default-extensions: OverloadedStrings LambdaCase QuasiQuotes ScopedTypeVariables   build-depends:       base >=4.3 && <5-    , conferer >=0.3.0.0 && <0.5.0.0+    , conferer >=0.4.0.0 && <0.5.0.0     , hedis >=0.7.0 && <1.0.0     , text >=1.1 && <1.3   default-language: Haskell2010@@ -49,7 +49,7 @@   default-extensions: OverloadedStrings LambdaCase QuasiQuotes ScopedTypeVariables   build-depends:       base >=4.3 && <5-    , conferer >=0.3.0.0 && <0.5.0.0+    , conferer >=0.4.0.0 && <0.5.0.0     , conferer-hedis     , hedis >=0.7.0 && <1.0.0     , hspec
src/Conferer/FromConfig/Hedis.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeApplications #-}+{-# LANGUAGE CPP #-} module Conferer.FromConfig.Hedis   (   -- * How to use this@@ -33,8 +34,12 @@   fetchFromConfig = fetchFromConfigWith (\t -> do       case readMaybe $ unpack t of         Just n -> return $ Redis.PortNumber n-        Nothing ->+        Nothing -> do+#ifdef mingw32_HOST_OS+          Nothing+#else           return $ Redis.UnixSocket $ unpack t+#endif     )  instance DefaultConfig Redis.ConnectInfo where@@ -45,14 +50,19 @@     return Nothing    updateFromConfig key config connectInfo = do-    redisConfig <- getKey key config-      >>= \case+    redisConfig <-+-- For hedis < 0.10.0 `Redis.parseConnectInfo` doesn't exist so in that case+-- we simply avoid reading the url directly from key, and instead we directly+-- act as if it wasn't present+#if MIN_VERSION_hedis(0,10,0)+      getKey key config >>= \case         Just connectionString ->           case Redis.parseConnectInfo $ unpack connectionString of             Right con -> return $ con             Left e ->                 throwIO $ ConfigParsingError key connectionString (typeRep (Proxy :: Proxy (Redis.ConnectInfo)))         Nothing ->+#endif           pure connectInfo             >>= findKeyAndApplyConfig config key "host" Redis.connectHost (\v c -> c { Redis.connectHost = v })             >>= findKeyAndApplyConfig config key "port" Redis.connectPort (\v c -> c { Redis.connectPort = v })
test/Conferer/FromConfig/HedisSpec.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Conferer.FromConfig.HedisSpec where  import           Test.Hspec@@ -8,7 +9,7 @@ import qualified Database.Redis as Redis  configWith :: [(Key, Text)] -> IO Config-configWith keyValues = emptyConfig & addProvider (mkMapProvider keyValues)+configWith keyValues = emptyConfig & addSource (mkMapSource keyValues)  portAndHostShouldBe :: Redis.ConnectInfo -> (Redis.PortID, Int) -> Expectation portAndHostShouldBe fetchedSettings (port, host) = do@@ -34,6 +35,8 @@       config <- configWith [("hedis.maxConnections", "6")]       fetchedValue <- getFromConfig "hedis" config       fetchedValue `portAndHostShouldBe` (defaultPort, 6)++#if MIN_VERSION_hedis(0,10,0)   describe "fetching a hedis configuration overriding its host" $ do     it "returns a hedis config with its host set to the overriden one" $ do       config <- configWith [("hedis", "redis://username:password@host:42")]@@ -47,3 +50,4 @@         ]       fetchedValue <- getFromConfig "hedis" config       fetchedValue `portAndHostShouldBe` (Redis.PortNumber 42, 70)+#endif