packages feed

tmp-postgres 1.23.0.3 → 1.24.0.0

raw patch · 7 files changed

+34/−31 lines, 7 files

Files

CHANGELOG.md view
@@ -1,5 +1,8 @@ Changelog for tmp-postgres +1.24.0.0+  #185 rename makeDataDirPermanent to makeDataDirectoryPermanent+ 1.23.0.3   #122 Try to minize failed deletes ... again. 
src/Database/Postgres/Temp.hs view
@@ -68,7 +68,7 @@   , toTemporaryDirectory   , toPostgresqlConf   -- *** 'DB' modifiers-  , makeDataDirPermanent+  , makeDataDirectoryPermanent   , reloadConfig   -- *** 'DB' debugging   , prettyPrintDB
src/Database/Postgres/Temp/Internal.hs view
@@ -31,7 +31,7 @@ --   @since 1.12.0.0 data DB = DB   { dbResources :: Resources-  -- ^ Temporary resources and the final 'CompletePlan'.+  -- ^ Temporary resources and the final 'Plan'.   , dbPostgresProcess :: PostgresProcess   -- ^ @postgres@ process handle and the connection options.   }@@ -77,14 +77,14 @@ need to setup your own bracket like   @-    bracket (fmap 'makeDataDirPermanent' 'start') (either mempty 'stop')+    bracket (fmap 'makeDataDirectoryPermanent' 'start') (either mempty 'stop')  @  -@since 1.12.0.0+@since 1.24.0.0 -}-makeDataDirPermanent :: DB -> DB-makeDataDirPermanent db = db+makeDataDirectoryPermanent :: DB -> DB+makeDataDirectoryPermanent db = db   { dbResources = makeResourcesDataDirPermanent $ dbResources db   } @@ -356,7 +356,7 @@ restart :: DB -> IO (Either StartError DB) restart db@DB{..} = try $ do   void $ stopPostgres db-  let CompletePlan{..} = resourcesPlan dbResources+  let Plan{..} = resourcesPlan dbResources       startAction = startPostgresProcess completePlanConnectionTimeout completePlanLogger         completePlanPostgres   bracketOnError startAction stopPlan $ \result ->
src/Database/Postgres/Temp/Internal/Config.hs view
@@ -1,13 +1,13 @@ {-# OPTIONS_HADDOCK prune #-} {-| This module provides types and functions for combining partial-    configs into a complete configs to ultimately make a 'CompletePlan'.+    configs into a complete configs to ultimately make a 'Plan'.      This module has two classes of types.      Types like 'ProcessConfig' that could be used by any     library that  needs to combine process options. -    Finally it has types and functions for creating 'CompletePlan's that+    Finally it has types and functions for creating 'Plan's that     use temporary resources. This is used to create the default     behavior of 'Database.Postgres.Temp.startConfig' and related     functions.@@ -415,8 +415,8 @@ flattenConfig = unlines . map (\(x, y) -> x <> "=" <> y) .   Map.toList . Map.fromList --- | Turn a 'Config' into a 'CompletePlan'. Fails if any values are missing.-completePlan :: [(String, String)] -> String -> Config -> Either [String] CompletePlan+-- | Turn a 'Config' into a 'Plan'. Fails if any values are missing.+completePlan :: [(String, String)] -> String -> Config -> Either [String] Plan completePlan envs dataDirectoryString config@Config {..} = do   (   completePlanLogger     , completePlanInitDb@@ -440,7 +440,7 @@       completePlanCopy = completeCopyDirectory completePlanDataDirectory <$>         join (getLast copyConfig) -  pure CompletePlan {..}+  pure Plan {..}  -- Returns 'True' if the 'Config' has a -- 'Just' 'initDbConfig'.@@ -634,8 +634,8 @@       ("--pgdata=" <> theDataDirectory) : completeProcessConfigCmdLine x   } -cachePlan :: CompletePlan -> Bool -> FilePath -> IO CompletePlan-cachePlan plan@CompletePlan {..} cow cacheDirectory = case completePlanInitDb of+cachePlan :: Plan -> Bool -> FilePath -> IO Plan+cachePlan plan@Plan {..} cow cacheDirectory = case completePlanInitDb of   Nothing -> pure plan   Just theConfig -> do     let (mtheDataDirectory, clearedConfig) = splitDataDirectory theConfig@@ -741,7 +741,7 @@         (toFilePath resourcesDataDir)       finalPlan = hostAndDir <> config   uncachedPlan <- lift $-    either (throwIO . CompletePlanFailed (show $ pretty finalPlan)) pure $+    either (throwIO . PlanFailed (show $ pretty finalPlan)) pure $       completePlan envs (toFilePath resourcesDataDir) finalPlan   resourcesPlan <- lift $ maybe (pure uncachedPlan) (uncurry $ cachePlan uncachedPlan) resourcesInitDbCache   pure Resources {..}@@ -759,13 +759,13 @@ prettyPrintConfig = show . pretty  -- | 'Resources' holds a description of the temporary folders (if there are any)---   and includes the final 'CompletePlan' that can be used with 'startPlan'.+--   and includes the final 'Plan' that can be used with 'startPlan'. --   See 'setupConfig' for an example of how to create a 'Resources'. -- --   @since 1.12.0.0 data Resources = Resources-  { resourcesPlan    :: CompletePlan-  -- ^ Final 'CompletePlan'. See 'startPlan' for information on 'CompletePlan's.+  { resourcesPlan    :: Plan+  -- ^ Final 'Plan'. See 'startPlan' for information on 'Plan's.   , resourcesSocketDirectory :: CompleteDirectoryType   -- ^ The used to potentially cleanup the temporary unix socket directory.   , resourcesDataDir :: CompleteDirectoryType
src/Database/Postgres/Temp/Internal/Core.hs view
@@ -76,8 +76,8 @@     }   -- ^ @createdb@ failed. This can be from invalid configuration or   --   the database might already exist.-  | CompletePlanFailed String [String]-  -- ^ The 'Database.Postgres.Temp.Config.Plan' was missing info and a complete 'CompletePlan' could+  | PlanFailed String [String]+  -- ^ The 'Database.Postgres.Temp.Config.Plan' was missing info and a complete 'Plan' could   --   not be created.   | CompleteProcessConfigFailed String [String]   -- ^ The 'Database.Postgres.Temp.Config.ProcessConfig' was missing info and a@@ -369,17 +369,17 @@   (res, stdOut, stdErr) <- executeProcessAndTee "createdb" config   throwIfNotSuccess (CreateDbFailed stdOut stdErr) res ---------------------------------------------------------------------------------- CompletePlan+-- Plan ---------------------------------------------------------------------------------- | 'CompletePlan' is the low level configuration necessary for initializing+-- | 'Plan' is the low level configuration necessary for initializing --   a database cluster --   starting @postgres@ and creating a database. There is no validation done---   on the 'CompletePlan'. It is recommend that one use the higher level+--   on the 'Plan'. It is recommend that one use the higher level --   functions --   such as 'Database.Postgres.Temp.start' which will generate plans that---   are valid. 'CompletePlan's are used internally but are exposed if the+--   are valid. 'Plan's are used internally but are exposed if the --   higher level plan generation is not sufficent.-data CompletePlan = CompletePlan+data Plan = Plan   { completePlanLogger            :: Logger   , completePlanInitDb            :: Maybe CompleteProcessConfig   , completePlanCopy              :: Maybe CompleteCopyDirectoryCommand@@ -390,8 +390,8 @@   , completePlanConnectionTimeout :: Int   } -instance Pretty CompletePlan where-  pretty CompletePlan {..}+instance Pretty Plan where+  pretty Plan {..}     =   text "completePlanInitDb:"     <>  softline     <>  indent 2 (pretty completePlanInitDb)@@ -420,8 +420,8 @@ --   Additionally it writes a \"postgresql.conf\" and does not return until --   the @postgres@ process is ready. See 'startPostgresProcess' for more --   details.-startPlan :: CompletePlan -> IO PostgresProcess-startPlan plan@CompletePlan {..} = do+startPlan :: Plan -> IO PostgresProcess+startPlan plan@Plan {..} = do   completePlanLogger $ StartPlan $ show $ pretty plan   for_ completePlanInitDb executeInitDb 
test/Main.hs view
@@ -314,7 +314,7 @@   it "makeResourcesDataDirPermanent works" $     withTempDirectory "/tmp" "tmp-postgres-make-premanent" $ \dirPath -> do        let config = defaultConfig { temporaryDirectory = pure dirPath }-       pathToCheck <- bracket (either throwIO (pure . makeDataDirPermanent) =<< startConfig config) stop $+       pathToCheck <- bracket (either throwIO (pure . makeDataDirectoryPermanent) =<< startConfig config) stop $         pure . toDataDirectory        doesDirectoryExist pathToCheck >>= \case          True -> pure ()
tmp-postgres.cabal view
@@ -1,5 +1,5 @@ name:                tmp-postgres-version:             1.23.0.3+version:             1.24.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