tmp-proc-redis-0.6.0.1: Launch Redis in docker using tmp-proc
Copyright(c) 2020-2021 Tim Emiola
LicenseBSD3
MaintainerTim Emiola <adetokunbo@users.noreply.github.com >
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.TmpProc.Docker.Redis

Description

Provides an instance of Proc that launches redis as a tmp proc.

The instance this module provides can be used in integration tests as is.

It's also possible to write other instances that launch redis in different ways; for those, this instance can be used as a reference example.

Synopsis

Proc instance

newtype TmpRedis Source #

Provides the capability to launch a redis instance as tmp proc.

The constructor receives the names of keys to be dropped on reset.

Constructors

TmpRedis [KeyName] 

Instances

Instances details
Connectable TmpRedis Source #

Specifies how to connect to a tmp redis service.

Instance details

Defined in System.TmpProc.Docker.Redis

Associated Types

type Conn TmpRedis = (conn :: Type) #

Proc TmpRedis Source #

Specifies how to run redis as a tmp proc.

Instance details

Defined in System.TmpProc.Docker.Redis

Associated Types

type Image TmpRedis :: Symbol #

type Name TmpRedis = (labelName :: Symbol) #

type Conn TmpRedis Source # 
Instance details

Defined in System.TmpProc.Docker.Redis

type Image TmpRedis Source # 
Instance details

Defined in System.TmpProc.Docker.Redis

type Image TmpRedis = "redis:5.0"
type Name TmpRedis Source # 
Instance details

Defined in System.TmpProc.Docker.Redis

type Name TmpRedis = "a-redis-db"

Useful definitions

aProc :: HList '[TmpRedis] Source #

A singleton HList containing an example TmpRedis.

aHandle :: IO (HandlesOf '[TmpRedis]) Source #

An HList that just contains the handle created from aProc.

type KeyName = ByteString Source #

The name of a key in redis.

Re-exports

class (KnownSymbol (Image a), KnownSymbol (Name a)) => Proc a where #

Specifies how to launch a temporary process using Docker.

Minimal complete definition

uriOf, reset, ping

Associated Types

type Image a :: Symbol #

The image name of the docker image, e.g, postgres:10.6

type Name a = (labelName :: Symbol) | labelName -> a #

A label used to refer to running process created from this image, e.g, a-postgres-db

Methods

runArgs :: [Text] #

Additional arguments to the docker command that launches the tmp proc.

uriOf :: HostIpAddress -> SvcURI #

Determines the service URI of the process, when applicable.

reset :: ProcHandle a -> IO () #

Resets some state in a tmp proc service.

ping :: ProcHandle a -> IO Pinged #

Checks if the tmp proc started ok.

pingCount :: Natural #

Maximum number of pings to perform during startup.

pingGap :: Natural #

Number of milliseconds between pings.

Instances

Instances details
Proc TmpRedis Source #

Specifies how to run redis as a tmp proc.

Instance details

Defined in System.TmpProc.Docker.Redis

Associated Types

type Image TmpRedis :: Symbol #

type Name TmpRedis = (labelName :: Symbol) #

type family Name a = (labelName :: Symbol) | labelName -> a #

A label used to refer to running process created from this image, e.g, a-postgres-db

Instances

Instances details
type Name TmpRedis Source # 
Instance details

Defined in System.TmpProc.Docker.Redis

type Name TmpRedis = "a-redis-db"

data HList (a :: [Type]) where #

Defines a Heterogenous list.

Constructors

HNil :: HList ('[] :: [Type]) 
HCons :: forall anyTy (manyTys :: [Type]). anyTy -> HList manyTys -> HList (anyTy ': manyTys) infixr 5 

Instances

Instances details
(Show x, Show (HList xs)) => Show (HList (x ': xs)) 
Instance details

Defined in System.TmpProc.TypeLevel

Methods

showsPrec :: Int -> HList (x ': xs) -> ShowS #

show :: HList (x ': xs) -> String #

showList :: [HList (x ': xs)] -> ShowS #

Show (HList ('[] :: [Type])) 
Instance details

Defined in System.TmpProc.TypeLevel

Methods

showsPrec :: Int -> HList '[] -> ShowS #

show :: HList '[] -> String #

showList :: [HList '[]] -> ShowS #

(Eq x, Eq (HList xs)) => Eq (HList (x ': xs)) 
Instance details

Defined in System.TmpProc.TypeLevel

Methods

(==) :: HList (x ': xs) -> HList (x ': xs) -> Bool #

(/=) :: HList (x ': xs) -> HList (x ': xs) -> Bool #

Eq (HList ('[] :: [Type])) 
Instance details

Defined in System.TmpProc.TypeLevel

Methods

(==) :: HList '[] -> HList '[] -> Bool #

(/=) :: HList '[] -> HList '[] -> Bool #

type HandlesOf (procs :: [Type]) = HList (Proc2Handle procs) #

A list of ProcHandle values.

type SvcURI = ByteString #

A connection string used to access the service once its running.

type HostIpAddress = Text #

The IP address of the docker host.

data Pinged #

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.

Constructors

OK

The service is running OK.

NotOK

The service is not running.

PingFailed Text

Contact to the service failed unexpectedly.

Instances

Instances details
Show Pinged 
Instance details

Defined in System.TmpProc.Docker

Eq Pinged 
Instance details

Defined in System.TmpProc.Docker

Methods

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

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

type family Image a :: Symbol #

The image name of the docker image, e.g, postgres:10.6

Instances

Instances details
type Image TmpRedis Source # 
Instance details

Defined in System.TmpProc.Docker.Redis

type Image TmpRedis = "redis:5.0"

class Proc a => Connectable a where #

Specifies how to a get a connection to a Proc.

Minimal complete definition

openConn

Associated Types

type Conn a = (conn :: Type) | conn -> a #

The connection type.

Methods

openConn :: ProcHandle a -> IO (Conn a) #

Get a connection to the Proc via its ProcHandle.

closeConn :: Conn a -> IO () #

Close a connection to a Proc.

Instances

Instances details
Connectable TmpRedis Source #

Specifies how to connect to a tmp redis service.

Instance details

Defined in System.TmpProc.Docker.Redis

Associated Types

type Conn TmpRedis = (conn :: Type) #

type family Conn a = (conn :: Type) | conn -> a #

The connection type.

Instances

Instances details
type Conn TmpRedis Source # 
Instance details

Defined in System.TmpProc.Docker.Redis

data ProcHandle a #

Provides access to a Proc that has been started.

Constructors

ProcHandle 

Fields

only :: x -> HList '[x] #

Construct a singleton HList

startupAll :: forall (procs :: [Type]). AreProcs procs => HList procs -> IO (HandlesOf procs) #

Start up processes for each Proc type.

withTmpConn :: Connectable a => ProcHandle a -> (Conn a -> IO b) -> IO b #

Run an action on a Connectable handle as a callback on its Conn