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 startPlan
for more details.
Synopsis
- data Event
- data StartError
- type Logger = Event -> IO ()
- waitForDB :: Logger -> Options -> IO ()
- data ProcessConfig = ProcessConfig {}
- startProcess :: String -> ProcessConfig -> IO ProcessHandle
- executeProcess :: String -> ProcessConfig -> IO ExitCode
- data PostgresPlan = PostgresPlan {}
- data PostgresProcess = PostgresProcess {}
- stopPostgresProcess :: PostgresProcess -> IO ExitCode
- startPostgresProcess :: Logger -> PostgresPlan -> IO PostgresProcess
- data Plan = Plan {}
- startPlan :: Plan -> IO PostgresProcess
- stopPlan :: PostgresProcess -> IO ExitCode
Documentation
Internal events for debugging
Constructors
StartPostgres | |
WaitForDB | |
StartPlan String | |
TryToConnect |
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 [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 :: 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 ProcessConfig Source #
ProcessConfig
contains the configuration necessary for starting a
process. It is essentially a stripped down CreateProcess
.
Constructors
ProcessConfig | |
Fields
|
Instances
Pretty ProcessConfig Source # | |
Defined in Database.Postgres.Temp.Internal.Core |
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
|
Instances
Pretty PostgresPlan Source # | |
Defined in Database.Postgres.Temp.Internal.Core |
data PostgresProcess Source #
The output of calling startPostgresProcess
.
Constructors
PostgresProcess | |
Fields
|
Instances
Pretty PostgresProcess Source # | |
Defined in Database.Postgres.Temp.Internal.Core |
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. Plan
s are used internally but are exposed if the higher
level plan generation is not sufficent.
Constructors
Plan | |
Fields |
startPlan :: Plan -> 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.