| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.Postgres.Temp.Internal.Config
Description
This module provides types and functions for combining partial
configs into a complete configs to ultimately make a Plan.
This module has two classes of types.
Types like ProcessConfig that could be used by any
library that needs to combine process options.
Finally it has types and functions for creating Plans that
use temporary resources. This is used to create the default
behavior of startConfig and related
functions.
|
Synopsis
- data Accum a
- data EnvironmentVariables = EnvironmentVariables {}
- completeEnvironmentVariables :: [(String, String)] -> EnvironmentVariables -> Either [String] [(String, String)]
- data CommandLineArgs = CommandLineArgs {}
- completeCommandLineArgs :: CommandLineArgs -> [String]
- data ProcessConfig = ProcessConfig {}
- standardProcessConfig :: ProcessConfig
- devNull :: Handle
- silentProcessConfig :: ProcessConfig
- completeProcessConfig :: [(String, String)] -> ProcessConfig -> Either [String] CompleteProcessConfig
- data CompleteDirectoryType
- toFilePath :: CompleteDirectoryType -> FilePath
- data DirectoryType
- setupDirectoryType :: String -> String -> DirectoryType -> IO CompleteDirectoryType
- cleanupDirectoryType :: CompleteDirectoryType -> IO ()
- completePostgresPlan :: [(String, String)] -> Config -> Either [String] CompletePostgresPlan
- completePlan :: [(String, String)] -> String -> Config -> Either [String] Plan
- data Config = Config {
- logger :: Last Logger
- initDbConfig :: Accum ProcessConfig
- copyConfig :: Last (Maybe CopyDirectoryCommand)
- createDbConfig :: Accum ProcessConfig
- postgresConfig :: ProcessConfig
- connectionOptions :: Options
- postgresConfigFile :: [(String, String)]
- connectionTimeout :: Last Int
- socketDirectory :: DirectoryType
- dataDirectory :: DirectoryType
- port :: Last (Maybe Int)
- temporaryDirectory :: Last FilePath
- initDbCache :: Last (Maybe (Bool, FilePath))
- data CopyDirectoryCommand = CopyDirectoryCommand {}
- toPlan :: Bool -> Bool -> Int -> FilePath -> FilePath -> Config
- setupConfig :: Config -> IO Resources
- cleanupConfig :: Resources -> IO ()
- prettyPrintConfig :: Config -> String
- data Resources = Resources {}
- makeResourcesDataDirPermanent :: Resources -> Resources
- optionsToConfig :: Options -> Config
Documentation
Accum is a monoid.
It's <> behavior is analogous to 1 and 0 with *. Think of DontCare
as 1 and Zlich as 0.
The behavior of Merge is like Justs.
Since: 1.17.0.0
data EnvironmentVariables Source #
The environment variables can be declared to inherit from the running process or they can be specifically added.
Since: 1.12.0.0
Instances
completeEnvironmentVariables :: [(String, String)] -> EnvironmentVariables -> Either [String] [(String, String)] Source #
data CommandLineArgs Source #
A type to help combine command line Args.
Since: 1.12.0.0
Constructors
| CommandLineArgs | |
Fields | |
Instances
completeCommandLineArgs :: CommandLineArgs -> [String] Source #
This convert the CommandLineArgs to '[String]'.
Since: 1.12.0.0
data ProcessConfig Source #
Process configuration
Since: 1.12.0.0
Constructors
| ProcessConfig | |
Fields
| |
Instances
standardProcessConfig :: ProcessConfig Source #
The standardProcessConfig sets the handles to stdin, stdout and
stderr and inherits the environment variables from the calling
process.
Since: 1.12.0.0
silentProcessConfig :: ProcessConfig Source #
silentProcessConfig sets the handles to /dev/null and
inherits the environment variables from the calling process.
Since: 1.12.0.0
completeProcessConfig :: [(String, String)] -> ProcessConfig -> Either [String] CompleteProcessConfig Source #
Turn a ProcessConfig into a ProcessConfig. Fails if
any values are missing.
Since: 1.12.0.0
data CompleteDirectoryType Source #
A type to track whether a file is temporary and needs to be cleaned up.
Since: 1.12.0.0
Constructors
| CPermanent FilePath | |
| CTemporary FilePath |
Instances
toFilePath :: CompleteDirectoryType -> FilePath Source #
Get the file path of a CompleteDirectoryType, regardless if it is a
CPermanent or CTemporary type.
Since: 1.12.0.0
data DirectoryType Source #
Used to specify a Temporary folder that is automatically
cleaned up or a Permanent folder which is not
automatically cleaned up.
Since: 1.12.0.0
Constructors
| Permanent FilePath | A permanent file that should not be generated. |
| Temporary | A temporary file that needs to generated. |
Instances
Arguments
| :: String | Temporary directory configuration |
| -> String | Directory pattern |
| -> DirectoryType | |
| -> IO CompleteDirectoryType |
Either create aCTemporary directory or do create the directory
if it does not exist to a CPermanent
one.
Since: 1.29.0.0
cleanupDirectoryType :: CompleteDirectoryType -> IO () Source #
Either remove a CTemporary directory or do nothing to a CPermanent
one.
completePostgresPlan :: [(String, String)] -> Config -> Either [String] CompletePostgresPlan Source #
Turn a Config into a CompletePostgresPlan. Fails if any
values are missing.
The high level options for overriding default behavior.
Since: 1.22.0.0
Constructors
| Config | |
Fields
| |
Instances
data CopyDirectoryCommand Source #
Copy command used to create a data directory. If initdb used to create the
data directory directly this is not needed.
If destinationDirectory is Nothing then the dataDirectory
(which might be generated) is used.
Since: 1.16.0.0
Constructors
| CopyDirectoryCommand | |
Fields | |
Instances
Arguments
| :: Bool | Make |
| -> Bool | Make |
| -> Int | The port. |
| -> FilePath | Socket directory. |
| -> FilePath | The |
| -> Config |
Create a Config that sets the command line options of all processes
(initdb, postgres and createdb). This the generated plan
that is combined with the extra plan from
startConfig.
cleanupConfig :: Resources -> IO () Source #
Free the temporary resources created by setupConfig.
Resources holds a description of the temporary folders (if there are any)
and includes the final Plan that can be used with startPlan.
See setupConfig for an example of how to create a Resources.
Since: 1.12.0.0
Constructors
| Resources | |
Fields
| |
makeResourcesDataDirPermanent :: Resources -> Resources Source #
Make the resourcesDataDir CPermanent so it will not
get cleaned up.
Since: 1.12.0.0
optionsToConfig :: Options -> Config Source #