| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.Postgres.Temp.Internal.Core
Description
This module provides the low level functionality for running initdb, postgres and createdb to make a database.
See initPlan for more details.
Synopsis
- data Event
- data StartError
- type Logger = Event -> IO ()
- waitForDB :: Options -> IO ()
- data ProcessConfig = ProcessConfig {}
- startProcess :: String -> ProcessConfig -> IO ProcessHandle
- executeProcess :: String -> ProcessConfig -> IO ExitCode
- data PostgresPlan = PostgresPlan {}
- data PostgresProcess = PostgresProcess {}
- terminateConnections :: Options -> IO ()
- stopPostgresProcess :: PostgresProcess -> IO ExitCode
- startPostgresProcess :: Logger -> PostgresPlan -> IO PostgresProcess
- data Plan = Plan {}
- throwIfNotSuccess :: Exception e => (ExitCode -> e) -> ExitCode -> IO ()
- initPlan :: Plan -> IO PostgresProcess
- shutdownPlan :: PostgresProcess -> IO ExitCode
Documentation
Internal events for debugging
Constructors
| StartPostgres | |
| WaitForDB |
data StartError Source #
A list of failures that can occur when starting. This is not and exhaustive list but covers the errors that the system catches for the user.
Constructors
| StartPostgresFailed ExitCode |
|
| InitDbFailed ExitCode |
|
| CreateDbFailed ExitCode |
|
| CompletePlanFailed [String] | The |
Instances
| Eq StartError Source # | |
Defined in Database.Postgres.Temp.Internal.Core | |
| Ord StartError Source # | |
Defined in Database.Postgres.Temp.Internal.Core Methods compare :: StartError -> StartError -> Ordering # (<) :: StartError -> StartError -> Bool # (<=) :: StartError -> StartError -> Bool # (>) :: StartError -> StartError -> Bool # (>=) :: StartError -> StartError -> Bool # max :: StartError -> StartError -> StartError # min :: StartError -> StartError -> StartError # | |
| Show StartError Source # | |
Defined in Database.Postgres.Temp.Internal.Core Methods showsPrec :: Int -> StartError -> ShowS # show :: StartError -> String # showList :: [StartError] -> ShowS # | |
| Exception StartError Source # | |
Defined in Database.Postgres.Temp.Internal.Core Methods toException :: StartError -> SomeException # fromException :: SomeException -> Maybe StartError # displayException :: StartError -> String # | |
waitForDB :: Options -> IO () Source #
postgres is not ready until we are able to successfully connect.
waitForDB attempts to connect over and over again and returns
after the first successful connection.
data ProcessConfig Source #
ProcessConfig contains the configuration necessary for starting a
process. It is essentially a stripped down CreateProcess.
Constructors
| ProcessConfig | |
Fields
| |
Arguments
| :: String | Process name |
| -> ProcessConfig | Process config |
| -> IO ProcessHandle |
Start a process interactively and return the ProcessHandle
Arguments
| :: String | Process name |
| -> ProcessConfig | Process config |
| -> IO ExitCode |
Start a process and block until it finishes return the ExitCode.
data PostgresPlan Source #
PostgresPlan is used be startPostgresProcess to start the postgres
and then attempt to connect to it.
Constructors
| PostgresPlan | |
Fields
| |
data PostgresProcess Source #
The output of calling startPostgresProcess.
Constructors
| PostgresProcess | |
Fields
| |
terminateConnections :: Options -> IO () Source #
Force all connections to the database to close. Called during shutdown as well.
stopPostgresProcess :: PostgresProcess -> IO ExitCode Source #
Stop the postgres process after attempting to terminate all the
connections.
startPostgresProcess :: Logger -> PostgresPlan -> IO PostgresProcess Source #
Start the postgres process and block until a successful connection
occurs. A separate thread we continously check to see if the postgres
process has crashed.
Plan is the low level configuration necessary for creating a database
starting postgres and creating a database. There is no validation done
on the Plan. It is recommend that one use the higher level functions
such as start which will generate plans that
are valid. Plans are used internally but are exposed if the higher
level plan generation is not sufficent.
Constructors
| Plan | |
Fields | |
throwIfNotSuccess :: Exception e => (ExitCode -> e) -> ExitCode -> IO () Source #
A simple helper to throw ExitCodes when they are ExitFailure.
initPlan :: Plan -> IO PostgresProcess Source #
initPlan optionally calls initdb, optionally calls createdb and
unconditionally calls postgres.
Additionally it writes a "postgresql.conf" and does not return until
the postgres process is ready. See startPostgresProcess for more
details.
shutdownPlan :: PostgresProcess -> IO ExitCode Source #
Stop the postgres process. See stopPostgresProcess for more details.