diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ced94b..42e2dcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.2.1.1] - 2023-08-21 +### Added +- `NEO4J_BOLT_VERSION` configuration. + ## [0.2.1.0] - 2021-04-24 ### Changed - Added `HasCallStack` to unsafe functions; diff --git a/bcd-config.cabal b/bcd-config.cabal index aaa3832..2ce0c4f 100644 --- a/bcd-config.cabal +++ b/bcd-config.cabal @@ -1,5 +1,5 @@ name: bcd-config -version: 0.2.1.0 +version: 0.2.1.1 synopsis: Library to get config. description: Library to get config to different systems homepage: https://github.com/biocad/bcd-config#readme diff --git a/src/System/BCD/Config.hs b/src/System/BCD/Config.hs index 776468f..41ba58c 100644 --- a/src/System/BCD/Config.hs +++ b/src/System/BCD/Config.hs @@ -41,12 +41,19 @@ loadDotenv = liftIO $ void $ loadFile defaultConfig class Typeable a => GetEnv a where getEnv :: (HasCallStack, MonadIO m) => String -> m a getEnv key = do - valueM <- liftIO $ lookupEnv key + valueM <- getEnvMaybe key case valueM of Nothing -> error $ "bcd-config: could not find environment <" <> key <> ">" + Just val -> return val + + getEnvMaybe :: (HasCallStack, MonadIO m) => String -> m (Maybe a) + getEnvMaybe key = do + valueM <- liftIO $ lookupEnv key + case valueM of + Nothing -> return Nothing Just val -> case convertSafe val of Nothing -> error $ "bcd-config: could not parse environment <" <> key <> "> = <" <> val <> ">" <> " as type " <> show (typeRep @a) - Just a -> return a + Just a -> return $ Just a convert :: HasCallStack => String -> a convert = fromJust . convertSafe diff --git a/src/System/BCD/Config/Neo4j.hs b/src/System/BCD/Config/Neo4j.hs index 80dc708..2945579 100644 --- a/src/System/BCD/Config/Neo4j.hs +++ b/src/System/BCD/Config/Neo4j.hs @@ -12,6 +12,7 @@ module System.BCD.Config.Neo4j , timeout , rps , descr + , version ) where import Control.DeepSeq (NFData) @@ -33,6 +34,7 @@ data Neo4jConfig = Neo4jConfig { _host :: String , _timeout :: Int , _rps :: Int , _descr :: String + , _version :: Maybe Int } deriving (Show, Read, Eq, Generic) @@ -61,4 +63,5 @@ instance FromDotenv Neo4jConfig where _timeout <- getEnv "NEO4J_TIMEOUT" _rps <- getEnv "NEO4J_RPS" _descr <- getEnv "NEO4J_DESCR" + _version <- getEnvMaybe "NEO4J_BOLT_VERSION" pure Neo4jConfig{..}