Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides the high level functions that are re-exported
by Database.Postgres.Temp
. Additionally it includes some
identifiers that are used for testing but are not exported.
Synopsis
- data DB = DB {}
- toConnectionString :: DB -> ByteString
- defaultPostgresConfig :: [String]
- defaultConfig :: Config
- standardConfig :: IO Config
- startWith :: Config -> IO (Either StartError DB)
- start :: IO (Either StartError DB)
- stop :: DB -> IO ()
- stopPostgres :: DB -> IO ExitCode
- restart :: DB -> IO (Either StartError DB)
- reloadConfig :: DB -> IO ()
- withPlan :: Config -> (DB -> IO a) -> IO (Either StartError a)
- with :: (DB -> IO a) -> IO (Either StartError a)
- withRestart :: DB -> (DB -> IO a) -> IO (Either StartError a)
- optionsToDefaultConfig :: Options -> Config
Documentation
Handle for holding temporary resources, the postgres
process handle
and postgres connection information. The DB
also includes the
final Plan
that was used to start initdb
, createdb
and
postgres
.
DB | |
|
toConnectionString :: DB -> ByteString Source #
defaultPostgresConfig :: [String] Source #
Default postgres options
defaultConfig :: Config Source #
The default configuration. This will create a database called "test"
and create a temporary directory for the data and a temporary directory
for a unix socket on a random port.
If you would like to customize this behavior you can start with the
defaultConfig
and overwrite fields or combine the Config
with another
config using <>
(mappend
).
If you would like complete control over the behavior of initdb
,
postgres
and createdb
you can call the internal function initPlan
directly although this should not be necessary.
standardConfig :: IO Config Source #
standardConfig
makes a default config with standardProcessConfig
.
It is used by default but can be overriden by the extra config.
:: Config |
|
-> IO (Either StartError DB) |
Create temporary resources and use them to make a Config
.
The generated Config
is combined with the passed in extraConfiguration
to create a Plan
that is used to create a database.
The output DB
includes references to the temporary resources for
cleanup and the final plan that was used to generate the database and
processes
start :: IO (Either StartError DB) Source #
Default start behavior. Equivalent to calling startWith
with the
defaultConfig
Stop the postgres
process and cleanup any temporary directories that
might have been created.
stopPostgres :: DB -> IO ExitCode Source #
Only stop the postgres
process but leave any temporary resources.
Useful for testing backup strategies when used in conjunction with
restart
or withRestart
.
reloadConfig :: DB -> IO () Source #
Reload the configuration file without shutting down. Calls
pg_reload_conf()
.
:: Config |
|
-> (DB -> IO a) |
|
-> IO (Either StartError a) |
Exception safe default database create. Takes an action
continuation
which is given a DB
it can use to connect
to (see toConnectionString
or postgresProcessClientConfig
).
All of the database resources are automatically cleaned up on
completion even in the face of exceptions.
:: (DB -> IO a) |
|
-> IO (Either StartError a) |
Default expectation safe interface. Equivalent to withPlan
the
defaultConfig
withRestart :: DB -> (DB -> IO a) -> IO (Either StartError a) Source #
Exception safe version of restart