packages feed

tmp-postgres 1.21.1.1 → 1.22.0.0

raw patch · 6 files changed

+52/−33 lines, 6 files

Files

CHANGELOG.md view
@@ -1,5 +1,8 @@ Changelog for tmp-postgres +1.22.0.0+  #174 Better postgresql.conf type.+ 1.21.1.1   #172 Fix verboseLogging not working 
src/Database/Postgres/Temp.hs view
@@ -68,6 +68,7 @@   , toConnectionOptions   , toDataDirectory   , toTemporaryDirectory+  , toPostgresqlConf   -- *** 'DB' modifiers   , makeDataDirPermanent   , reloadConfig
src/Database/Postgres/Temp/Internal.hs view
@@ -93,6 +93,14 @@ --   @since 1.12.0.0 toTemporaryDirectory :: DB -> FilePath toTemporaryDirectory = resourcesTemporaryDir . dbResources++{-|+Get the final @postgresql.conf@++@since 1.22.0.0+-}+toPostgresqlConf :: DB -> String+toPostgresqlConf = completePlanConfig . resourcesPlan . dbResources ------------------------------------------------------------------------------- -- Life Cycle Management -------------------------------------------------------------------------------@@ -112,16 +120,16 @@  @since 1.21.0.0 -}-fastPostgresConfig :: [String]+fastPostgresConfig :: [(String, String)] fastPostgresConfig =-  [ "shared_buffers = 12MB"-  , "fsync = off"-  , "synchronous_commit = off"-  , "full_page_writes = off"-  , "log_min_messages = PANIC"-  , "log_min_error_statement = PANIC"-  , "log_statement = none"-  , "client_min_messages = ERROR"+  [ ("shared_buffers", "12MB")+  , ("fsync", "off")+  , ("synchronous_commit", "off")+  , ("full_page_writes", "off")+  , ("log_min_messages", "PANIC")+  , ("log_min_error_statement", "PANIC")+  , ("log_statement", "none")+  , ("client_min_messages", "ERROR")   ]  {-|@@ -196,7 +204,7 @@ defaultConfig :: Config defaultConfig = mempty   { plan = mempty-    { postgresConfigFile = verbosePostgresConfig+    { postgresConfigFile = fastPostgresConfig     , initDbConfig = pure mempty       { commandLine = mempty         { keyBased = Map.singleton "--no-sync" Nothing@@ -217,7 +225,7 @@ defaultConfig_9_3_10 :: Config defaultConfig_9_3_10 = mempty   { plan = mempty-    { postgresConfigFile = verbosePostgresConfig+    { postgresConfigFile = fastPostgresConfig     , initDbConfig = pure mempty       { commandLine = mempty         { keyBased = Map.singleton "--nosync" Nothing@@ -246,7 +254,7 @@  @since 1.21.0.0 -}-defaultPostgresConf :: [String] -> Config+defaultPostgresConf :: [(String, String)] -> Config defaultPostgresConf extra = defaultConfig <> mempty   { plan = mempty     { postgresConfigFile = extra@@ -256,16 +264,16 @@ -- | Default postgres options -- --   @since 1.21.0.0-verbosePostgresConfig :: [String]+verbosePostgresConfig :: [(String, String)] verbosePostgresConfig =-  [ "shared_buffers = 12MB"-  , "fsync = off"-  , "synchronous_commit = off"-  , "full_page_writes = off"-  , "log_min_duration_statement = 0"-  , "log_connections = on"-  , "log_disconnections = on"-  , "client_min_messages = WARNING"+  [ ("shared_buffers", "12MB")+  , ("fsync", "off")+  , ("synchronous_commit", "off")+  , ("full_page_writes", "off")+  , ("log_min_duration_statement", "0")+  , ("log_connections", "on")+  , ("log_disconnections", "on")+  , ("client_min_messages", "WARNING")   ]  {-|
src/Database/Postgres/Temp/Internal/Config.hs view
@@ -439,7 +439,7 @@   , copyConfig :: Last (Maybe CopyDirectoryCommand)   , createDbConfig :: Accum ProcessConfig   , postgresPlan :: PostgresPlan-  , postgresConfigFile :: [String]+  , postgresConfigFile :: [(String, String)]   , dataDirectoryString :: Last String   , connectionTimeout :: Last Int   -- ^ Max time to spend attempting to connection to @postgres@.@@ -468,12 +468,16 @@     <> hardline     <> text "postgresConfigFile:"     <> softline-    <> indent 2 (vsep $ map text postgresConfigFile)+    <> indent 2 (vsep $ map (\(x, y) -> text x <> "=" <> text y) postgresConfigFile)     <> hardline     <> text "dataDirectoryString:" <+> pretty (getLast dataDirectoryString)     <> hardline     <> text "connectionTimeout:" <+> pretty (getLast connectionTimeout) +flattenConfig :: [(String, String)] -> String+flattenConfig = unlines . map (\(x, y) -> x <> "=" <> y) .+  Map.toList . Map.fromList+ -- | Turn a 'Plan' into a 'CompletePlan'. Fails if any values are missing. completePlan :: [(String, String)] -> Plan -> Either [String] CompletePlan completePlan envs Plan {..} = do@@ -495,7 +499,7 @@         <*> getOption "dataDirectoryString" dataDirectoryString         <*> getOption "connectionTimeout" connectionTimeout -  let completePlanConfig = unlines postgresConfigFile+  let completePlanConfig = flattenConfig postgresConfigFile       completePlanCopy = completeCopyDirectory completePlanDataDirectory <$>         join (getLast copyConfig) @@ -557,10 +561,10 @@     <> hardline     <> text "initDbCache:" <+> pretty (getLast initDbCache) -socketDirectoryToConfig :: FilePath -> [String]+socketDirectoryToConfig :: FilePath -> [(String, String)] socketDirectoryToConfig dir =-    [ "listen_addresses = '127.0.0.1,::1'"-    , "unix_socket_directories = '" <> dir <> "'"+    [ ("listen_addresses", "'127.0.0.1,::1'")+    , ("unix_socket_directories", "'" <> dir <> "'")     ]  -------------------------------------------------------------------------------@@ -1038,7 +1042,7 @@ -- | Lens for 'postgresConfigFile'. -- --   @since 1.12.0.0-postgresConfigFileL :: Lens' Plan [String]+postgresConfigFileL :: Lens' Plan [(String, String)] postgresConfigFileL f plan@Plan{..}   = fmap (\x -> plan { postgresConfigFile = x })       (f postgresConfigFile)
test/Main.hs view
@@ -177,7 +177,7 @@   let     cConfig = mempty       { plan = mempty-        { postgresConfigFile = ["log_min_duration_statement='100ms'"]+        { postgresConfigFile = [("log_min_duration_statement","'100ms'")]         }       } @@ -384,6 +384,9 @@     withDbCache $ \cacheInfo ->       either throwIO pure =<< withConfig (cacheResourcesToConfig cacheInfo) assertConnection +  it "postgresql.conf append last wins" $+    withConfig' (defaultPostgresConf [("fsync", "on")]) $ \db -> do+      toPostgresqlConf db `shouldContain` "fsync=on" -- -- Error Plans. Can't be combined. Just list them out inline since they can't be combined --@@ -644,9 +647,9 @@       Set.isSubsetOf wordsToSearchFor    let justBackupResources = defaultPostgresConf-        [ "wal_level=replica"-        , "archive_mode=on"-        , "max_wal_senders=2"+        [ ("wal_level", "replica")+        , ("archive_mode","on")+        , ("max_wal_senders","2")         ]       backupResources = justBackupResources 
tmp-postgres.cabal view
@@ -1,5 +1,5 @@ name:                tmp-postgres-version:             1.21.1.1+version:             1.22.0.0 synopsis: Start and stop a temporary postgres description: Start and stop a temporary postgres. See README.md homepage:            https://github.com/jfischoff/tmp-postgres#readme