| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.Postgres.Temp.Internal
Synopsis
- getFreePort :: IO Int
- waitForDB :: Options -> IO ()
- withLock :: MVar a -> IO b -> IO b
- data DB = DB {}
- connectionString :: DB -> String
- data SocketClass
- data Options = Options {}
- defaultOptions :: Options
- start :: Options -> IO (Either StartError DB)
- startLocalhost :: Options -> 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 -> Options -> Handle -> Handle -> IO (Either StartError DB)
- startWithHandlesAndDir :: SocketClass -> Options -> 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 -> Options -> FilePath -> Handle -> Handle -> IO (Either StartError DB)
- startAndLogToTmp :: Options -> IO (Either StartError DB)
- terminateConnections :: DB -> IO ()
- stop :: DB -> IO (Maybe ExitCode)
- data InitDbOptions = InitDbOptions {}
- defaultInitDbOptions :: InitDbOptions
- initDbToCommandLingArgs :: InitDbOptions -> [String]
Documentation
getFreePort :: IO Int Source #
Constructors
| DB | |
Fields
| |
connectionString :: DB -> String Source #
data SocketClass Source #
Instances
Constructors
| Options | |
Fields
| |
Arguments
| :: Options | Extra options which override the defaults |
| -> IO (Either StartError DB) |
start postgres and use the current processes stdout and stderr
startLocalhost :: Options -> IO (Either StartError DB) Source #
start postgres and use the current processes stdout and stderr but use TCP on localhost instead of a unix socket.
data StartError Source #
Constructors
| InitDBFailed ExitCode | |
| CreateDBFailed [String] ExitCode | |
| StartPostgresFailed [String] ExitCode | |
| StartPostgresDisappeared [String] |
Instances
| Eq StartError Source # | |
Defined in Database.Postgres.Temp.Internal | |
| Show StartError Source # | |
Defined in Database.Postgres.Temp.Internal Methods showsPrec :: Int -> StartError -> ShowS # show :: StartError -> String # showList :: [StartError] -> ShowS # | |
| Exception StartError Source # | |
Defined in Database.Postgres.Temp.Internal Methods toException :: StartError -> SomeException # fromException :: SomeException -> Maybe StartError # displayException :: StartError -> String # | |
throwIfError :: (ExitCode -> StartError) -> ExitCode -> IO () Source #
Arguments
| :: SocketClass | |
| -> Options | 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 -> Options -> FilePath -> Handle -> Handle -> IO (Either StartError DB) Source #
data AnotherPostgresProcessActive Source #
This error is thrown is startPostgres is called twice without calling
stopPostgres first.
Constructors
| AnotherPostgresProcessActive |
Instances
| Eq AnotherPostgresProcessActive Source # | |
Defined in Database.Postgres.Temp.Internal Methods (==) :: AnotherPostgresProcessActive -> AnotherPostgresProcessActive -> Bool # (/=) :: AnotherPostgresProcessActive -> AnotherPostgresProcessActive -> Bool # | |
| Show AnotherPostgresProcessActive Source # | |
Defined in Database.Postgres.Temp.Internal Methods showsPrec :: Int -> AnotherPostgresProcessActive -> ShowS # show :: AnotherPostgresProcessActive -> String # showList :: [AnotherPostgresProcessActive] -> ShowS # | |
| Exception AnotherPostgresProcessActive Source # | |
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 #
Constructors
| InitDB | |
| WriteConfig | |
| FreePort | |
| StartPostgres | |
| WaitForDB | |
| CreateDB | |
| Finished |
rmDirIgnoreErrors :: FilePath -> IO () Source #
startWithLogger :: (Event -> IO ()) -> SocketClass -> Options -> FilePath -> Handle -> Handle -> IO (Either StartError DB) Source #
Arguments
| :: Options | Extra options which override the defaults |
| -> IO (Either StartError DB) |
terminateConnections :: DB -> IO () Source #
Force all connections to the database to close. Can be useful in some testing situations. Called during shutdown as well.
data InitDbOptions Source #
Constructors
| InitDbOptions | |
Fields
| |