tmp-postgres-1.7.0.0: Start and stop a temporary postgres

Safe HaskellNone
LanguageHaskell2010

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

Documentation

data Event Source #

Internal events for debugging

Instances
Eq Event Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Core

Methods

(==) :: Event -> Event -> Bool #

(/=) :: Event -> Event -> Bool #

Ord Event Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Core

Methods

compare :: Event -> Event -> Ordering #

(<) :: Event -> Event -> Bool #

(<=) :: Event -> Event -> Bool #

(>) :: Event -> Event -> Bool #

(>=) :: Event -> Event -> Bool #

max :: Event -> Event -> Event #

min :: Event -> Event -> Event #

Show Event Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Core

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

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

postgres failed before a connection succeeded. Most likely this is due to invalid configuration

InitDbFailed ExitCode

initdb failed. This can be from invalid configuration or using a non-empty data directory

CreateDbFailed ExitCode

createdb failed. This can be from invalid configuration or the database might already exist.

CompletePlanFailed String [String]

The PartialPlan was missing info and a complete Plan could not be created.

type Logger = Event -> IO () Source #

A way to log internal Events

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

startProcess Source #

Arguments

:: String

Process name

-> ProcessConfig

Process config

-> IO ProcessHandle 

Start a process interactively and return the ProcessHandle

executeProcess Source #

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

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.

data Plan Source #

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.

Instances
Pretty Plan Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Core

Methods

pretty :: Plan -> Doc #

prettyList :: [Plan] -> Doc #

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.