Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides the low level functionality for running initdb
, postgres
and createdb
to make a database.
See startPlan
for more details.
Synopsis
- data Event
- data StartError
- type Logger = Event -> IO ()
- waitForDB :: Logger -> Options -> IO ()
- data CompleteProcessConfig = CompleteProcessConfig {}
- startProcess :: String -> CompleteProcessConfig -> IO ProcessHandle
- stopProcess :: ProcessHandle -> IO ExitCode
- executeProcess :: String -> CompleteProcessConfig -> IO ExitCode
- data CompletePostgresPlan = CompletePostgresPlan {}
- data PostgresProcess = PostgresProcess {}
- stopPostgresProcess :: PostgresProcess -> IO ExitCode
- startPostgresProcess :: Logger -> CompletePostgresPlan -> IO PostgresProcess
- data CompletePlan = CompletePlan {}
- startPlan :: CompletePlan -> IO PostgresProcess
- stopPlan :: PostgresProcess -> IO ExitCode
Documentation
Internal events for debugging
StartPlan String | The first event. This useful for debugging
what is actual passed to the |
StartPostgres | The second event. Postgres is about to get called |
WaitForDB | The third event. Postgres started. We are not about to setup a reconnect loop (racing with a process checker) |
TryToConnect | The fourth event and (possibly all subsequent events).
We are looping trying to successfully connect to the |
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.
StartPostgresFailed ExitCode |
|
InitDbFailed ExitCode |
|
CreateDbFailed ExitCode |
|
CompletePlanFailed String [String] | The |
Instances
Eq StartError Source # | |
Defined in Database.Postgres.Temp.Internal.Core (==) :: StartError -> StartError -> Bool # (/=) :: StartError -> StartError -> Bool # | |
Ord StartError Source # | |
Defined in Database.Postgres.Temp.Internal.Core 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 showsPrec :: Int -> StartError -> ShowS # show :: StartError -> String # showList :: [StartError] -> ShowS # | |
Exception StartError Source # | |
Defined in Database.Postgres.Temp.Internal.Core toException :: StartError -> SomeException # fromException :: SomeException -> Maybe StartError # displayException :: StartError -> String # |
waitForDB :: Logger -> 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 CompleteProcessConfig Source #
CompleteProcessConfig
contains the configuration necessary for starting a
process. It is essentially a stripped down CreateProcess
.
CompleteProcessConfig | |
|
Instances
Pretty CompleteProcessConfig Source # | |
Defined in Database.Postgres.Temp.Internal.Core pretty :: CompleteProcessConfig -> Doc # prettyList :: [CompleteProcessConfig] -> Doc # |
:: String | Process name |
-> CompleteProcessConfig | Process config |
-> IO ProcessHandle |
Start a process interactively and return the ProcessHandle
stopProcess :: ProcessHandle -> IO ExitCode Source #
Stop a ProcessHandle
. An alias for waitForProcess
:: String | Process name |
-> CompleteProcessConfig | Process config |
-> IO ExitCode |
Start a process and block until it finishes return the ExitCode
.
data CompletePostgresPlan Source #
CompletePostgresPlan
is used be startPostgresProcess
to start the postgres
and then attempt to connect to it.
CompletePostgresPlan | |
|
Instances
Pretty CompletePostgresPlan Source # | |
Defined in Database.Postgres.Temp.Internal.Core pretty :: CompletePostgresPlan -> Doc # prettyList :: [CompletePostgresPlan] -> Doc # |
data PostgresProcess Source #
The output of calling startPostgresProcess
.
PostgresProcess | |
|
Instances
Pretty PostgresProcess Source # | |
Defined in Database.Postgres.Temp.Internal.Core pretty :: PostgresProcess -> Doc # prettyList :: [PostgresProcess] -> Doc # |
stopPostgresProcess :: PostgresProcess -> IO ExitCode Source #
Stop the postgres
process after attempting to terminate all the
connections.
startPostgresProcess :: Logger -> CompletePostgresPlan -> 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.
data CompletePlan Source #
CompletePlan
is the low level configuration necessary for creating a database
starting postgres
and creating a database. There is no validation done
on the CompletePlan
. It is recommend that one use the higher level functions
such as start
which will generate plans that
are valid. CompletePlan
s are used internally but are exposed if the higher
level plan generation is not sufficent.
Instances
Pretty CompletePlan Source # | |
Defined in Database.Postgres.Temp.Internal.Core pretty :: CompletePlan -> Doc # prettyList :: [CompletePlan] -> Doc # |
startPlan :: CompletePlan -> IO PostgresProcess Source #
startPlan
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.
stopPlan :: PostgresProcess -> IO ExitCode Source #
Stop the postgres
process. See stopPostgresProcess
for more details.