-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Run 'tmp' processes in integration tests -- -- tmp-proc runs services in docker containers for use in -- integration tests. It aims to make using these services become like -- accessing tmp processes, similar to how tmp file or -- directories are used. It aspires to provide a user-friendly API, while -- including useful features such as * launch of multiple services on -- docker during test setup * delayed test execution until the launched -- services are available * simplified use of connections to the services -- from a WAI server under test * good integration with haskell -- testing frameworks like hspec and tasty @package tmp-proc @version 0.6.2.0 -- | Defines type-level combinators for performing a merge sort of -- type-level lists. -- -- SortSymbols sorts type-level lists of Symbols. -- -- The other exported combinators make it easy to implement type-level -- merge sort for similar type-level lists. -- -- This is an internal module that provides type-level functions used in -- various constraints in System.TmpProc.Docker. module System.TmpProc.TypeLevel.Sort -- | Sort a list of type-level symbols using merge sort. -- --

Examples

-- --
--   >>> :kind! SortSymbols '["xyz", "def", "abc"]
--   SortSymbols '["xyz", "def", "abc"] :: [Symbol]
--   = '["abc", "def", "xyz"]
--   
type family SortSymbols (xs :: [Symbol]) :: [Symbol] -- | Takes 1 element at a time from a list until the desired length is -- reached. -- --

Examples

-- --
--   >>> :kind! Take '["a", "b", "c", "d"] 2
--   Take '["a", "b", "c", "d"] 2 :: [Symbol]
--   = '["a", "b"]
--   
type family Take (xs :: [k]) (n :: Nat) :: [k] -- | Drops 1 element at a time until the the dropped target is reached. -- --

Examples

-- --
--   >>> :kind! Drop '["a", "b", "c", "d"] 2
--   Drop '["a", "b", "c", "d"] 2 :: [Symbol]
--   = '["c", "d"]
--   
-- --
--   >>> :kind! Drop '["a"] 2
--   Drop '["a"] 2 :: [Symbol]
--   = '[]
--   
type family Drop (xs :: [k]) (n :: Nat) :: [k] -- | Counts a list, 1 element at a time. -- --

Examples

-- --
--   >>> :kind! CmpNat 4 (LengthOf '[1, 2, 3, 4])
--   CmpNat 4 (LengthOf '[1, 2, 3, 4]) :: Ordering
--   = 'EQ
--   
type family LengthOf (xs :: [k]) :: Nat -- | Computes the midpoint of a number. -- -- N.B: maximum value that this works for depends on the reduction limit -- of the type-checker. -- --

Examples

-- --
--   >>> :kind! CmpNat 49 (HalfOf 99)
--   CmpNat 49 (HalfOf 99) :: Ordering
--   = 'EQ
--   
-- --
--   >>> :kind! CmpNat 50 (HalfOf 100)
--   CmpNat 50 (HalfOf 100) :: Ordering
--   = 'EQ
--   
type family HalfOf (n :: Nat) :: Nat -- | Defines type-level data structures and combinators used by -- System.TmpProc.Docker and System.TmpProc.Warp. -- -- HList implements a heterogenous list used to define types that -- represent multiple concurrent tmp procs. -- -- KV is intended for internal use within the tmp-proc -- package. It allows indexing and sorting of lists of tmp procs. module System.TmpProc.TypeLevel -- | Defines a Heterogenous list. data HList :: [Type] -> Type [HNil] :: HList '[] [HCons] :: anyTy -> HList manyTys -> HList (anyTy : manyTys) infixr 5 `HCons` -- | An infix alias for HCons. (&:) :: x -> HList xs -> HList (x : xs) infixr 5 &: -- | Construct a singleton HList only :: x -> HList '[x] -- | An infix alias for both. (&:&) :: x -> y -> HList '[x, y] infixr 6 &:& -- | Construct a two-item HList. both :: x -> y -> HList '[x, y] infixr 6 `both` -- | Obtain the first element of a HList. hHead :: HList (a : as) -> a -- | Get an item in an HList given its type. hOf :: forall y xs. IsInProof y xs => Proxy y -> HList xs -> y -- | Allows reordering of similar HLists. -- --

Examples

-- --
--   >>> hReorder @_ @'[Bool, Int] ('c' &: (3 :: Int) &: True &: (3.1 :: Double) &: HNil)
--   True &: 3 &: HNil
--   
-- --
--   >>> hReorder @_ @'[Double, Bool, Int] ('c' &: (3 :: Int) &: True &: (3.1 :: Double) &: HNil)
--   3.1 &: True &: 3 &: HNil
--   
class ReorderH xs ys hReorder :: ReorderH xs ys => HList xs -> HList ys -- | Use a type-level symbol as key type that indexes a value -- type. data KV :: Symbol -> Type -> Type [V] :: a -> KV s a -- | Select an item from an HList of KVs by -- key. -- -- N.B Returns the first item. It assumes the keys in the KV HList -- are unique. TODO: enforce this rule using a constraint. -- --

Examples

-- --
--   >>> select @"d" @Double  @'[KV "b" Bool, KV "d" Double] (V True &:  V (3.1 :: Double) &: HNil)
--   3.1
--   
select :: forall k t xs. MemberKV k t xs => HList xs -> t -- | Select items with specified keys from an HList of -- KVs by key. -- -- N.B. this this is an internal function. -- -- The keys must be provided in the same order as they occur in the -- HList, any other order will likely result in an compiler error. -- --

Examples

-- --
--   >>> selectMany @'["b"] @'[Bool] @'[KV "b" Bool, KV "d" Double] (V True &:  V (3.1 :: Double) &: HNil)
--   True &: HNil
--   
selectMany :: forall ks ts xs. ManyMemberKV ks ts xs => HList xs -> HList ts -- | Proves a symbol and its type occur as entry in a list of -- KV types. data LookupKV (k :: Symbol) t (xs :: [Type]) [AtHead] :: LookupKV k t (KV k t : kvs) [OtherKeys] :: LookupKV k t kvs -> LookupKV k t (KV ok ot : kvs) -- | Generate proof instances of LookupKV. class MemberKV (k :: Symbol) (t :: Type) (xs :: [Type]) lookupProof :: MemberKV k t xs => LookupKV k t xs -- | Generate proof instances of LookupMany. class ManyMemberKV (ks :: [Symbol]) (ts :: [Type]) (kvs :: [Type]) manyProof :: ManyMemberKV ks ts kvs => LookupMany ks ts kvs -- | A constraint that confirms that a type is not present in a type-level -- list. type family IsAbsent e r :: Constraint -- | Generate proof instances of IsIn. class IsInProof t (tys :: [Type]) instance (System.TmpProc.TypeLevel.IsInProof y xs, System.TmpProc.TypeLevel.ReorderH xs ys) => System.TmpProc.TypeLevel.ReorderH xs (y : ys) instance System.TmpProc.TypeLevel.IsInProof t (t : tys) instance System.TmpProc.TypeLevel.IsInProof t tys => System.TmpProc.TypeLevel.IsInProof t (a : tys) instance System.TmpProc.TypeLevel.ReorderH xs '[] instance System.TmpProc.TypeLevel.ManyMemberKV '[k] '[t] (System.TmpProc.TypeLevel.KV k t : ks) instance System.TmpProc.TypeLevel.ManyMemberKV ks ts kvs => System.TmpProc.TypeLevel.ManyMemberKV (k : ks) (t : ts) (System.TmpProc.TypeLevel.KV k t : kvs) instance System.TmpProc.TypeLevel.ManyMemberKV ks ts kvs => System.TmpProc.TypeLevel.ManyMemberKV ks ts (System.TmpProc.TypeLevel.KV ok ot : kvs) instance System.TmpProc.TypeLevel.MemberKV k t '[System.TmpProc.TypeLevel.KV k t] instance System.TmpProc.TypeLevel.MemberKV k t (System.TmpProc.TypeLevel.KV k t : kvs) instance System.TmpProc.TypeLevel.MemberKV k t kvs => System.TmpProc.TypeLevel.MemberKV k t (System.TmpProc.TypeLevel.KV ok ot : kvs) instance GHC.Show.Show (System.TmpProc.TypeLevel.HList '[]) instance (GHC.Show.Show x, GHC.Show.Show (System.TmpProc.TypeLevel.HList xs)) => GHC.Show.Show (System.TmpProc.TypeLevel.HList (x : xs)) instance GHC.Classes.Eq (System.TmpProc.TypeLevel.HList '[]) instance (GHC.Classes.Eq x, GHC.Classes.Eq (System.TmpProc.TypeLevel.HList xs)) => GHC.Classes.Eq (System.TmpProc.TypeLevel.HList (x : xs)) -- | Provides the core data types and combinators used to launch temporary -- (tmp) processes (procs) using docker. -- -- tmp-proc aims to simplify integration tests that use -- dockerizable services. -- -- -- -- This module does all that via its data types: -- -- module System.TmpProc.Docker -- | Specifies how to launch a temporary process using Docker. class (KnownSymbol (Image a), KnownSymbol (Name a)) => Proc a where { -- | The image name of the docker image, e.g, postgres:10.6 type Image a :: Symbol; -- | A label used to refer to running process created from this image, e.g, -- a-postgres-db type Name a = (labelName :: Symbol) | labelName -> a; } -- | Additional arguments to the docker command that launches the tmp proc. runArgs :: Proc a => [Text] -- | Determines the service URI of the process, when applicable. uriOf :: Proc a => HostIpAddress -> SvcURI -- | Resets some state in a tmp proc service. reset :: Proc a => ProcHandle a -> IO () -- | Checks if the tmp proc started ok. ping :: Proc a => ProcHandle a -> IO Pinged -- | Maximum number of pings to perform during startup. pingCount :: Proc a => Natural -- | Number of milliseconds between pings. pingGap :: Proc a => Natural -- | Indicates the result of pinging a Proc. -- -- If the ping succeeds, ping should return OK. -- -- ping should catch any exceptions that are expected when the -- Procs service is not available and return -- NotOK. -- -- startupAll uses PingFailed to report any unexpected -- exceptions that escape ping. data Pinged -- | The service is running OK. OK :: Pinged -- | The service is not running. NotOK :: Pinged -- | Contact to the service failed unexpectedly. PingFailed :: Text -> Pinged -- | Declares a proof that a list of types only contains -- Procs. class AreProcs as -- | Name of a process. nameOf :: forall a. Proc a => a -> Text -- | Starts a Proc. -- -- It uses ping to determine if the Proc started up ok, and -- will fail by throwing an exception if it did not. -- -- Returns the ProcHandle used to control the Proc once a -- ping has succeeded. startup :: ProcPlus a prepared => a -> IO (ProcHandle a) -- | Use an action that might throw an exception as a ping. toPinged :: forall e a. Exception e => Proxy e -> IO a -> IO Pinged -- | Simplifies use of uriOf. uriOf' :: forall a. Proc a => a -> HostIpAddress -> SvcURI -- | Simplifies use of runArgs. runArgs' :: forall a. Proc a => a -> [Text] -- | Allow customization of the docker command that launches a -- Proc -- -- The full command is `docker run -d optional-args --name $(name -- a) $(imageText a)` Specify a new instance of ToRunCmd to -- control optional-args -- -- There is an Overlappable fallback instance that works for any -- Proc, so this typeclass need only be specified for -- Proc that need extra args in the docker command class (Preparer a prepared) => ToRunCmd a prepared toRunCmd :: ToRunCmd a prepared => a -> prepared -> [Text] -- | Prepare resources for use by a Proc -- -- Preparation occurs before the Proc's docker container is a -- launched, and resources generated are made accessible via the -- prepared data type. -- -- Usually, it will be used by toRunCmd to provide -- additional arguments to the docker command -- -- There is an Overlappable fallback instance that works for any -- Proc, so this typeclass need only be specified for -- Proc that require some setup -- -- The prepare method is given a list of SlimHandle that -- represent preceding tmp-proc managed containers, to allow -- preparation to establish links to these containers when necessary class Preparer a prepared | a -> prepared prepare :: Preparer a prepared => [SlimHandle] -> a -> IO prepared -- | Start up processes for each Proc type. startupAll :: AreProcs procs => HList procs -> IO (HandlesOf procs) -- | Start up processes for each Proc type. startupAll' :: AreProcs procs => Maybe Text -> HList procs -> IO (NetworkHandlesOf procs) -- | Terminate all processes owned by some ProcHandles. terminateAll :: AreProcs procs => HandlesOf procs -> IO () -- | Like terminateAll, but also removes the docker network -- connecting the processes. netwTerminateAll :: AreProcs procs => NetworkHandlesOf procs -> IO () -- | Like startupAll but creates a new docker network and that the -- processes use netwStartupAll :: AreProcs procs => HList procs -> IO (NetworkHandlesOf procs) -- | Set up some Procs, run an action that uses them, then -- terminate them. withTmpProcs :: AreProcs procs => HList procs -> (HandlesOf procs -> IO b) -> IO b -- | Provides access to a Proc that has been started. data ProcHandle a ProcHandle :: !a -> !String -> !SvcURI -> !HostIpAddress -> ProcHandle a [hProc] :: ProcHandle a -> !a [hPid] :: ProcHandle a -> !String [hUri] :: ProcHandle a -> !SvcURI [hAddr] :: ProcHandle a -> !HostIpAddress -- | Provides an untyped view of the data in a ProcHandle data SlimHandle SlimHandle :: !Text -> !HostIpAddress -> !String -> !SvcURI -> SlimHandle [shName] :: SlimHandle -> !Text [shIpAddress] :: SlimHandle -> !HostIpAddress [shPid] :: SlimHandle -> !String [shUri] :: SlimHandle -> !SvcURI -- | Converts list of types to the corresponding ProcHandle -- types. type family Proc2Handle (as :: [Type]) = (handleTys :: [Type]) | handleTys -> as -- | Constraint alias used to constrain types where proxy of a Proc -- type looks up a value in an HList of ProcHandle. type HasHandle aProc procs = (Proc aProc, AreProcs procs, IsInProof (ProcHandle aProc) (Proc2Handle procs)) -- | Constraint alias used to constrain types where a Name looks up -- a type in an HList of ProcHandle. type HasNamedHandle name a procs = (name ~ Name a, Proc a, AreProcs procs, MemberKV name (ProcHandle a) (Handle2KV (Proc2Handle procs))) -- | Obtain the SlimHandle. slim :: Proc a => ProcHandle a -> SlimHandle -- | Obtain the handle matching the given type from a HList -- of ProcHandle. handleOf :: HandleOf a procs b => Proxy a -> HandlesOf procs -> ProcHandle b -- | Resets the handle whose index is specified by the proxy type. ixReset :: IxReset a procs => Proxy a -> HandlesOf procs -> IO () -- | Pings the handle whose index is specified by the proxy type. ixPing :: IxPing a procs => Proxy a -> HandlesOf procs -> IO Pinged -- | Obtains the service URI of the handle whose index is specified by the -- proxy type. ixUriOf :: IxUriOf a procs => Proxy a -> HandlesOf procs -> SvcURI -- | A list of ProcHandle values. type HandlesOf procs = HList (Proc2Handle procs) -- | A list of ProcHandle values with the docker network of -- their processes type NetworkHandlesOf procs = (Text, HandlesOf procs) -- | Select the named ProcHandles from an HList of -- ProcHandle. manyNamed :: SomeNamedHandles names namedProcs someProcs sortedProcs => Proxy names -> HandlesOf someProcs -> HandlesOf namedProcs -- | generate a random network name genNetworkName :: IO Text -- | Constraint alias when several Names are used to find -- matching types in an HList of ProcHandle. type SomeNamedHandles names procs someProcs sortedProcs = (names ~ Proc2Name procs, ManyMemberKV (SortSymbols names) (SortHandles (Proc2Handle procs)) (Handle2KV (Proc2Handle sortedProcs)), ReorderH (SortHandles (Proc2Handle procs)) (Proc2Handle procs), ReorderH (Proc2Handle someProcs) (Proc2Handle sortedProcs), AreProcs sortedProcs, SortHandles (Proc2Handle someProcs) ~ Proc2Handle sortedProcs) -- | Specifies how to a get a connection to a Proc. class (Proc a) => Connectable a where { -- | The connection type. type Conn a = (conn :: Type) | conn -> a; } -- | Get a connection to the Proc via its ProcHandle. openConn :: Connectable a => ProcHandle a -> IO (Conn a) -- | Close a connection to a Proc. closeConn :: Connectable a => Conn a -> IO () -- | Declares a proof that a list of types only contains -- Connectables. class Connectables as -- | Run an action on a Connectable handle as a callback on its -- Conn withTmpConn :: Connectable a => ProcHandle a -> (Conn a -> IO b) -> IO b -- | Builds on handleOf; gives the Conn of the -- ProcHandle to a callback. withConnOf :: (HandleOf idx procs namedConn, Connectable namedConn) => Proxy idx -> HandlesOf procs -> (Conn namedConn -> IO b) -> IO b -- | Open all the Connectable types to corresponding Conn -- types. openAll :: Connectables xs => HandlesOf xs -> IO (HList (ConnsOf xs)) -- | Close some Connectable types. closeAll :: Connectables procs => HList (ConnsOf procs) -> IO () -- | Open some connections, use them in an action; close them. withConns :: Connectables procs => HandlesOf procs -> (HList (ConnsOf procs) -> IO b) -> IO b -- | Open all known connections; use them in an action; close them. withKnownConns :: (AreProcs someProcs, Connectables conns, ReorderH (Proc2Handle someProcs) (Proc2Handle conns)) => HandlesOf someProcs -> (HList (ConnsOf conns) -> IO b) -> IO b -- | Open the named connections; use them in an action; close them. withNamedConns :: (SomeNamedHandles names namedConns someProcs sortedProcs, Connectables namedConns) => Proxy names -> HandlesOf someProcs -> (HList (ConnsOf namedConns) -> IO b) -> IO b -- | Determines if the docker daemon is accessible. hasDocker :: IO Bool -- | The IP address of the docker host. type HostIpAddress = Text -- | A connection string used to access the service once its running. type SvcURI = ByteString -- | Sort a list of type-level symbols using merge sort. -- --

Examples

-- --
--   >>> :kind! SortSymbols '["xyz", "def", "abc"]
--   SortSymbols '["xyz", "def", "abc"] :: [Symbol]
--   = '["abc", "def", "xyz"]
--   
type family SortSymbols (xs :: [Symbol]) :: [Symbol] -- | Computes the midpoint of a number. -- -- N.B: maximum value that this works for depends on the reduction limit -- of the type-checker. -- --

Examples

-- --
--   >>> :kind! CmpNat 49 (HalfOf 99)
--   CmpNat 49 (HalfOf 99) :: Ordering
--   = 'EQ
--   
-- --
--   >>> :kind! CmpNat 50 (HalfOf 100)
--   CmpNat 50 (HalfOf 100) :: Ordering
--   = 'EQ
--   
type family HalfOf (n :: Nat) :: Nat -- | Counts a list, 1 element at a time. -- --

Examples

-- --
--   >>> :kind! CmpNat 4 (LengthOf '[1, 2, 3, 4])
--   CmpNat 4 (LengthOf '[1, 2, 3, 4]) :: Ordering
--   = 'EQ
--   
type family LengthOf (xs :: [k]) :: Nat -- | Drops 1 element at a time until the the dropped target is reached. -- --

Examples

-- --
--   >>> :kind! Drop '["a", "b", "c", "d"] 2
--   Drop '["a", "b", "c", "d"] 2 :: [Symbol]
--   = '["c", "d"]
--   
-- --
--   >>> :kind! Drop '["a"] 2
--   Drop '["a"] 2 :: [Symbol]
--   = '[]
--   
type family Drop (xs :: [k]) (n :: Nat) :: [k] -- | Takes 1 element at a time from a list until the desired length is -- reached. -- --

Examples

-- --
--   >>> :kind! Take '["a", "b", "c", "d"] 2
--   Take '["a", "b", "c", "d"] 2 :: [Symbol]
--   = '["a", "b"]
--   
type family Take (xs :: [k]) (n :: Nat) :: [k] -- | Generate proof instances of IsIn. class IsInProof t (tys :: [Type]) -- | Allows reordering of similar HLists. -- --

Examples

-- --
--   >>> hReorder @_ @'[Bool, Int] ('c' &: (3 :: Int) &: True &: (3.1 :: Double) &: HNil)
--   True &: 3 &: HNil
--   
-- --
--   >>> hReorder @_ @'[Double, Bool, Int] ('c' &: (3 :: Int) &: True &: (3.1 :: Double) &: HNil)
--   3.1 &: True &: 3 &: HNil
--   
class ReorderH xs ys hReorder :: ReorderH xs ys => HList xs -> HList ys -- | Generate proof instances of LookupMany. class ManyMemberKV (ks :: [Symbol]) (ts :: [Type]) (kvs :: [Type]) -- | Generate proof instances of LookupKV. class MemberKV (k :: Symbol) (t :: Type) (xs :: [Type]) -- | A constraint that confirms that a type is not present in a type-level -- list. type family IsAbsent e r :: Constraint -- | Use a type-level symbol as key type that indexes a value -- type. data KV :: Symbol -> Type -> Type [V] :: a -> KV s a -- | Defines a Heterogenous list. data HList :: [Type] -> Type [HNil] :: HList '[] [HCons] :: anyTy -> HList manyTys -> HList (anyTy : manyTys) infixr 5 `HCons` -- | Obtain the first element of a HList. hHead :: HList (a : as) -> a -- | Get an item in an HList given its type. hOf :: forall y xs. IsInProof y xs => Proxy y -> HList xs -> y -- | An infix alias for HCons. (&:) :: x -> HList xs -> HList (x : xs) infixr 5 &: -- | Construct a two-item HList. both :: x -> y -> HList '[x, y] infixr 6 `both` -- | An infix alias for both. (&:&) :: x -> y -> HList '[x, y] infixr 6 &:& -- | Construct a singleton HList only :: x -> HList '[x] -- | Select an item from an HList of KVs by -- key. -- -- N.B Returns the first item. It assumes the keys in the KV HList -- are unique. TODO: enforce this rule using a constraint. -- --

Examples

-- --
--   >>> select @"d" @Double  @'[KV "b" Bool, KV "d" Double] (V True &:  V (3.1 :: Double) &: HNil)
--   3.1
--   
select :: forall k t xs. MemberKV k t xs => HList xs -> t -- | Select items with specified keys from an HList of -- KVs by key. -- -- N.B. this this is an internal function. -- -- The keys must be provided in the same order as they occur in the -- HList, any other order will likely result in an compiler error. -- --

Examples

-- --
--   >>> selectMany @'["b"] @'[Bool] @'[KV "b" Bool, KV "d" Double] (V True &:  V (3.1 :: Double) &: HNil)
--   True &: HNil
--   
selectMany :: forall ks ts xs. ManyMemberKV ks ts xs => HList xs -> HList ts instance GHC.Show.Show System.TmpProc.Docker.Pinged instance GHC.Classes.Eq System.TmpProc.Docker.Pinged instance GHC.Show.Show System.TmpProc.Docker.SlimHandle instance GHC.Classes.Eq System.TmpProc.Docker.SlimHandle instance System.TmpProc.Docker.Connectables '[] instance (System.TmpProc.Docker.Connectable a, System.TmpProc.Docker.Connectables as, System.TmpProc.TypeLevel.IsAbsent a as) => System.TmpProc.Docker.Connectables (a : as) instance System.TmpProc.Docker.HasHandle p procs => System.TmpProc.Docker.HandleOf p procs p instance System.TmpProc.Docker.HasHandle p procs => System.TmpProc.Docker.IxReset p procs instance System.TmpProc.Docker.HasHandle p procs => System.TmpProc.Docker.IxPing p procs instance System.TmpProc.Docker.HasHandle p procs => System.TmpProc.Docker.IxUriOf p procs instance System.TmpProc.Docker.HasNamedHandle name p procs => System.TmpProc.Docker.HandleOf name procs p instance System.TmpProc.Docker.HasNamedHandle name a procs => System.TmpProc.Docker.IxReset name procs instance System.TmpProc.Docker.HasNamedHandle name a procs => System.TmpProc.Docker.IxPing name procs instance System.TmpProc.Docker.HasNamedHandle name a procs => System.TmpProc.Docker.IxUriOf name procs instance System.TmpProc.Docker.AreProcs '[] instance (System.TmpProc.Docker.ProcPlus a prepared, System.TmpProc.Docker.AreProcs as, System.TmpProc.TypeLevel.IsAbsent a as) => System.TmpProc.Docker.AreProcs (a : as) instance (a GHC.Types.~ a', System.TmpProc.Docker.Proc a) => System.TmpProc.Docker.Preparer a a' instance (a GHC.Types.~ a', System.TmpProc.Docker.Proc a) => System.TmpProc.Docker.ToRunCmd a a' -- | Provides functions that make it easy to run Applications -- that access services running as tmp procs in -- integration tests. module System.TmpProc.Warp -- | Set up some ProcHandles then run an Application that -- uses them on a free port. -- -- Allows the app to configure itself using the tmp procs, then -- provides a callback with access to the handles. -- -- The tmp procs are shut down when the application is shut -- down. testWithApplication :: AreProcs procs => HList procs -> (HandlesOf procs -> IO Application) -> ((HandlesOf procs, Port) -> IO a) -> IO a -- | Set up some ProcHandles then run an Application that -- uses them on a free port. -- -- Allows the app to configure itself using the tmp procs, then -- provides a callback with access to the handles. -- -- Also runs a ready action that to determine if the application -- started correctly. -- -- The tmp procs are shut down when the application is shut -- down. testWithReadyApplication :: AreProcs procs => (Port -> IO ()) -> HList procs -> (HandlesOf procs -> IO Application) -> ((HandlesOf procs, Port) -> IO a) -> IO a -- | Like testWithApplication, but the port is secured using a -- 'Warp.TLSSettings. ' testWithTLSApplication :: AreProcs procs => TLSSettings -> HList procs -> (HandlesOf procs -> IO Application) -> ((HandlesOf procs, Port) -> IO a) -> IO a -- | Like testWithReadyApplication; the port is secured with -- TLSSettings. testWithReadyTLSApplication :: AreProcs procs => TLSSettings -> (Port -> IO ()) -> HList procs -> (HandlesOf procs -> IO Application) -> ((HandlesOf procs, Port) -> IO a) -> IO a -- | Represents a started Warp application and any AreProcs -- dependencies. data ServerHandle procs -- | The Port on which the ServerHandles server is running. serverPort :: ServerHandle procs -> Port -- | The ServerHandles ProcHandles. handles :: AreProcs procs => ServerHandle procs -> HandlesOf procs -- | Shuts down the ServerHandle server and its tmp proc -- dependencies. shutdown :: AreProcs procs => ServerHandle procs -> IO () -- | Runs an Application with ProcHandle dependencies on a -- free port. runServer :: AreProcs procs => HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) -- | Like runServer; with an additional ready that -- determines if the server is ready.'. runReadyServer :: AreProcs procs => (Port -> IO ()) -> HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) -- | Like runServer; the port is secured with TLSSettings. runTLSServer :: AreProcs procs => TLSSettings -> HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) -- | Like runReadyServer; the port is secured with -- TLSSettings. runReadyTLSServer :: AreProcs procs => TLSSettings -> (Port -> IO ()) -> HList procs -> (HandlesOf procs -> IO Application) -> IO (ServerHandle procs) -- | Simplifies writing the health checks used by ready variants -- of this module. checkHealth :: Int -> IO (Either a b) -> IO () -- | Exports all tmp-proc behaviour. -- -- tmp-proc is a package that aims to simplify writing -- integration tests that use dockerizable services. -- -- The package has the following structure: -- -- module System.TmpProc