Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- getFreePort :: IO Int
- waitForDB :: String -> IO ()
- withLock :: MVar a -> IO b -> IO b
- data DB = DB {
- mainDir :: FilePath
- connectionString :: String
- extraOptions :: [(String, String)]
- stdErr :: Handle
- stdOut :: Handle
- pidLock :: MVar ()
- port :: Int
- socketClass :: SocketClass
- pid :: IORef (Maybe ProcessHandle)
- data SocketClass
- start :: [(String, String)] -> IO (Either StartError DB)
- startLocalhost :: [(String, String)] -> IO (Either StartError DB)
- fourth :: (a, b, c, d) -> d
- procWith :: Handle -> Handle -> String -> [String] -> CreateProcess
- config :: Maybe FilePath -> String
- data StartError
- throwIfError :: (ExitCode -> StartError) -> ExitCode -> IO ()
- pidString :: ProcessHandle -> IO String
- runProcessWith :: Handle -> Handle -> String -> String -> [String] -> IO ExitCode
- startWithHandles :: SocketClass -> [(String, String)] -> Handle -> Handle -> IO (Either StartError DB)
- startWithHandlesAndDir :: SocketClass -> [(String, String)] -> FilePath -> Handle -> Handle -> IO (Either StartError DB)
- data AnotherPostgresProcessActive = AnotherPostgresProcessActive
- waitOnPostgres :: DB -> IO ()
- reloadConfig :: DB -> IO ()
- startPostgres :: DB -> IO ()
- stopPostgres :: DB -> IO (Maybe ExitCode)
- makePostgresOptions :: [(String, String)] -> FilePath -> Int -> [String]
- runPostgres :: Handle -> Handle -> [String] -> IO ProcessHandle
- data Event
- rmDirIgnoreErrors :: FilePath -> IO ()
- startWithLogger :: (Event -> IO ()) -> SocketClass -> [(String, String)] -> FilePath -> Handle -> Handle -> IO (Either StartError DB)
- startAndLogToTmp :: [(String, String)] -> IO (Either StartError DB)
- terminateConnections :: DB -> IO ()
- stop :: DB -> IO (Maybe ExitCode)
Documentation
getFreePort :: IO Int Source #
DB | |
|
data SocketClass Source #
Instances
start postgres and use the current processes stdout and stderr
start postgres and use the current processes stdout and stderr but use TCP on localhost instead of a unix socket.
data StartError Source #
InitDBFailed ExitCode | |
CreateDBFailed [String] ExitCode | |
StartPostgresFailed [String] ExitCode | |
StartPostgresDisappeared [String] |
Instances
Eq StartError Source # | |
Defined in Database.Postgres.Temp.Internal (==) :: StartError -> StartError -> Bool # (/=) :: StartError -> StartError -> Bool # | |
Show StartError Source # | |
Defined in Database.Postgres.Temp.Internal showsPrec :: Int -> StartError -> ShowS # show :: StartError -> String # showList :: [StartError] -> ShowS # | |
Exception StartError Source # | |
Defined in Database.Postgres.Temp.Internal toException :: StartError -> SomeException # fromException :: SomeException -> Maybe StartError # displayException :: StartError -> String # |
throwIfError :: (ExitCode -> StartError) -> ExitCode -> IO () Source #
:: SocketClass | |
-> [(String, String)] | Extra options which override the defaults |
-> Handle | stdout |
-> Handle | stderr |
-> IO (Either StartError DB) |
Start postgres and pass in handles for stdout and stderr
startWithHandlesAndDir :: SocketClass -> [(String, String)] -> FilePath -> Handle -> Handle -> IO (Either StartError DB) Source #
data AnotherPostgresProcessActive Source #
This error is thrown is startPostgres
is called twice without calling
stopPostgres
first.
Instances
waitOnPostgres :: DB -> IO () Source #
reloadConfig :: DB -> IO () Source #
Send the SIGHUP signal to the postgres process to start a config reload
startPostgres :: DB -> IO () Source #
This throws AnotherPostgresProcessActive
if the postgres
has not been stopped using stopPostgres
.
This function attempts to the pidLock
before running.
If postgres process fails this throws StartPostgresFailed
.
If the postgres process becomes Nothing
while starting
this function throws StartPostgresDisappeared
.
stopPostgres :: DB -> IO (Maybe ExitCode) Source #
Stop the postgres process. This function attempts to the pidLock
before running.
stopPostgres
will terminate all connections before shutting down postgres.
stopPostgres
is useful for testing backup strategies.
runPostgres :: Handle -> Handle -> [String] -> IO ProcessHandle Source #
rmDirIgnoreErrors :: FilePath -> IO () Source #
startWithLogger :: (Event -> IO ()) -> SocketClass -> [(String, String)] -> FilePath -> Handle -> Handle -> IO (Either StartError DB) Source #
terminateConnections :: DB -> IO () Source #
Force all connections to the database to close. Can be useful in some testing situations. Called during shutdown as well.