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

Safe HaskellNone
LanguageHaskell2010

Database.Postgres.Temp.Internal.Config

Description

This module provides types and functions for combining partial configs into a complete configs to ultimately make a CompletePlan.

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 CompletePlans that use temporary resources. This is used to create the default behavior of startConfig and related functions. |

Synopsis

Documentation

data EnvironmentVariables Source #

The environment variables can be declared to inherit from the running process or they can be specifically added.

Instances
Eq EnvironmentVariables Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Show EnvironmentVariables Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Generic EnvironmentVariables Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Associated Types

type Rep EnvironmentVariables :: Type -> Type #

Semigroup EnvironmentVariables Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Monoid EnvironmentVariables Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Pretty EnvironmentVariables Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

type Rep EnvironmentVariables Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

type Rep EnvironmentVariables = D1 (MetaData "EnvironmentVariables" "Database.Postgres.Temp.Internal.Config" "tmp-postgres-1.9.0.2-FLIHg8XKN1U6yEkdooj617" False) (C1 (MetaCons "EnvironmentVariables" PrefixI True) (S1 (MetaSel (Just "inherit") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Last Bool)) :*: S1 (MetaSel (Just "specific") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map String String))))

completeEnvironmentVariables :: [(String, String)] -> EnvironmentVariables -> Either [String] [(String, String)] Source #

Combine the current environment (if indicated by inherit) with specific

data CommandLineArgs Source #

A type to help combine command line Args.

Constructors

CommandLineArgs 

Fields

  • keyBased :: Map String (Maybe String)

    Args of the form -h foo, --host=foo and --switch. The key is mappended with value so the key should include the space or equals (as shown in the first two examples respectively). The Dual monoid is used so the last key wins.

  • indexBased :: Map Int String

    Args that appear at the end of the key based Args. The Dual monoid is used so the last key wins.

Instances
Eq CommandLineArgs Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Show CommandLineArgs Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Generic CommandLineArgs Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Associated Types

type Rep CommandLineArgs :: Type -> Type #

Semigroup CommandLineArgs Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Monoid CommandLineArgs Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Pretty CommandLineArgs Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

type Rep CommandLineArgs Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

type Rep CommandLineArgs = D1 (MetaData "CommandLineArgs" "Database.Postgres.Temp.Internal.Config" "tmp-postgres-1.9.0.2-FLIHg8XKN1U6yEkdooj617" False) (C1 (MetaCons "CommandLineArgs" PrefixI True) (S1 (MetaSel (Just "keyBased") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map String (Maybe String))) :*: S1 (MetaSel (Just "indexBased") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map Int String))))

data ProcessConfig Source #

Process configuration

Constructors

ProcessConfig 

Fields

Instances
Eq ProcessConfig Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Show ProcessConfig Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Generic ProcessConfig Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Associated Types

type Rep ProcessConfig :: Type -> Type #

Semigroup ProcessConfig Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Monoid ProcessConfig Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Pretty ProcessConfig Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

type Rep ProcessConfig Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

standardProcessConfig :: ProcessConfig Source #

The standardProcessConfig sets the handles to stdin, stdout and stderr and inherits the environment variables from the calling process.

toFilePath :: CompleteDirectoryType -> FilePath Source #

Get the file path of a CompleteDirectoryType, regardless if it is a CPermanent or CTemporary type.

data DirectoryType Source #

Used to specify a Temporary folder that is automatically cleaned up or a Permanent folder which is not automatically cleaned up.

Constructors

Permanent FilePath

A permanent file that should not be generated.

Temporary

A temporary file that needs to generated.

Instances
Eq DirectoryType Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Ord DirectoryType Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Show DirectoryType Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Semigroup DirectoryType Source #

Takes the last Permanent value.

Instance details

Defined in Database.Postgres.Temp.Internal.Config

Monoid DirectoryType Source #

Temporary as mempty

Instance details

Defined in Database.Postgres.Temp.Internal.Config

Pretty DirectoryType Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

setupDirectoryType Source #

Arguments

:: String

Temporary directory configuration

-> String

Directory pattern

-> DirectoryType 
-> IO CompleteDirectoryType 

Either create aCTemporary directory or do nothing to a CPermanent one.

cleanupDirectoryType :: CompleteDirectoryType -> IO () Source #

Either remove a CTemporary directory or do nothing to a CPermanent one.

data CompleteSocketClass Source #

A type for configuring the listening address of the postgres process. postgres can listen on several types of sockets simulatanously but we don't support that behavior. One can either listen on a IP based socket or a UNIX domain socket.

Constructors

CIpSocket String

IP socket type. The String is either an IP address or a host that will resolve to an IP address.

CUnixSocket CompleteDirectoryType

UNIX domain socket

Instances
Eq CompleteSocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Ord CompleteSocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Show CompleteSocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Generic CompleteSocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Associated Types

type Rep CompleteSocketClass :: Type -> Type #

Pretty CompleteSocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

type Rep CompleteSocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

type Rep CompleteSocketClass = D1 (MetaData "CompleteSocketClass" "Database.Postgres.Temp.Internal.Config" "tmp-postgres-1.9.0.2-FLIHg8XKN1U6yEkdooj617" False) (C1 (MetaCons "CIpSocket" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) :+: C1 (MetaCons "CUnixSocket" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CompleteDirectoryType)))

socketClassToConfig :: CompleteSocketClass -> [String] Source #

Create the extra config lines for listening based on the CompleteSocketClass

socketClassToHostFlag :: CompleteSocketClass -> [(String, Maybe String)] Source #

Many processes require a "host" flag. We can generate one from the CompleteSocketClass.

socketClassToHost :: CompleteSocketClass -> String Source #

Get the IP address, host name or UNIX domain socket directory as a String

data SocketClass Source #

The monoidial version of CompleteSocketClass. Used to combine overrides with defaults when creating a CompleteSocketClass. The monoid instance and combines the

Constructors

IpSocket (Last String)

The monoid for combining IP address configuration

UnixSocket DirectoryType

The monoid for combining UNIX socket configuration

Instances
Eq SocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Ord SocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Show SocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Generic SocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Associated Types

type Rep SocketClass :: Type -> Type #

Semigroup SocketClass Source #

Last IpSocket wins. UnixSocket DirectoryType as mappended together.

Instance details

Defined in Database.Postgres.Temp.Internal.Config

Monoid SocketClass Source #

Treats 'UnixSocket mempty' as mempty

Instance details

Defined in Database.Postgres.Temp.Internal.Config

Pretty SocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

type Rep SocketClass Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

type Rep SocketClass = D1 (MetaData "SocketClass" "Database.Postgres.Temp.Internal.Config" "tmp-postgres-1.9.0.2-FLIHg8XKN1U6yEkdooj617" False) (C1 (MetaCons "IpSocket" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Last String))) :+: C1 (MetaCons "UnixSocket" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 DirectoryType)))

setupSocketClass Source #

Arguments

:: String

Temporary directory

-> SocketClass

The type of socket

-> IO CompleteSocketClass 

Turn a SocketClass to a CompleteSocketClass. If the IpSocket is Nothing default to "127.0.0.1". If the is a UnixSocket optionally create a temporary directory if configured to do so.

cleanupSocketConfig :: CompleteSocketClass -> IO () Source #

Cleanup the UNIX socket temporary directory if one was created.

data PostgresPlan Source #

postgres process config and corresponding client connection Options.

Constructors

PostgresPlan 

Fields

data Plan Source #

Describe how to run initdb, createdb and postgres

Instances
Generic Plan Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Associated Types

type Rep Plan :: Type -> Type #

Methods

from :: Plan -> Rep Plan x #

to :: Rep Plan x -> Plan #

Semigroup Plan Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Methods

(<>) :: Plan -> Plan -> Plan #

sconcat :: NonEmpty Plan -> Plan #

stimes :: Integral b => b -> Plan -> Plan #

Monoid Plan Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Methods

mempty :: Plan #

mappend :: Plan -> Plan -> Plan #

mconcat :: [Plan] -> Plan #

Pretty Plan Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Methods

pretty :: Plan -> Doc #

prettyList :: [Plan] -> Doc #

type Rep Plan Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

completePlan :: [(String, String)] -> Plan -> Either [String] CompletePlan Source #

Turn a Plan into a CompletePlan. Fails if any values are missing.

data Config Source #

The high level options for overriding default behavior.

Constructors

Config 

Fields

Instances
Generic Config Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Associated Types

type Rep Config :: Type -> Type #

Methods

from :: Config -> Rep Config x #

to :: Rep Config x -> Config #

Semigroup Config Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Monoid Config Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Pretty Config Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

Methods

pretty :: Config -> Doc #

prettyList :: [Config] -> Doc #

type Rep Config Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

toPlan Source #

Arguments

:: Bool

Make initdb options

-> Bool

Make createdb options

-> Int

port

-> CompleteSocketClass

Whether to listen on a IP address or UNIX domain socket

-> FilePath

The postgres data directory

-> Plan 

Create a Plan that sets the command line options of all processes (initdb, postgres and createdb) using a

setupConfig Source #

Arguments

:: Config

extraConfig to mappend after the default config

-> IO Resources 

Create all the temporary resources from a Config. This also combines the Plan from toPlan with the extraConfig passed in.

cleanupConfig :: Resources -> IO () Source #

Free the temporary resources created by setupConfig

data Resources Source #

Resources holds a description of the temporary folders (if there are any) and includes the final CompletePlan that can be used with startPlan. See setupConfig for an example of how to create a Resources.

Constructors

Resources 

Fields

Instances
Pretty Resources Source # 
Instance details

Defined in Database.Postgres.Temp.Internal.Config

optionsToConfig :: Options -> Config Source #

Attempt to create a config from a Options. This is useful if want to create a database owned by a specific user you will also log in as among other use cases. It is possible some Options are not supported so don't hesitate to open an issue on github if you find one.

type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t Source #

Local Lens alias

type Lens' s a = Lens s s a a Source #

Local Lens' alias