Copyright | (c) Roman Gonzalez 20172018 |
---|---|
License | MIT |
Maintainer | open-source@roman-gonzalez.info |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Provides functions that help on the creation of Application teardown sub-routines
- class HasTeardown teardown where
- class IResource resource where
- data Teardown
- data TeardownResult
- = BranchResult {
- resultDescription :: !Description
- resultElapsedTime :: !NominalDiffTime
- resultDidFail :: !Bool
- resultListing :: ![TeardownResult]
- | LeafResult {
- resultDescription :: !Description
- resultElapsedTime :: !NominalDiffTime
- resultError :: !(Maybe SomeException)
- | EmptyResult {
- resultDescription :: !Description
- = BranchResult {
- runTeardown :: HasTeardown t => t -> IO TeardownResult
- runTeardown_ :: HasTeardown t => t -> IO ()
- emptyTeardown :: Description -> Teardown
- newTeardown :: IResource resource => Text -> resource -> IO Teardown
- didTeardownFail :: TeardownResult -> Bool
- failedToredownCount :: TeardownResult -> Int
- toredownCount :: TeardownResult -> Int
- prettyTeardownResult :: TeardownResult -> Doc
Typeclasses for extending teardown functionality
class HasTeardown teardown where Source #
A record that is or contains a Teardown
sub-routine should
instantiate this typeclass
getTeardown :: teardown -> Teardown Source #
Executes teardown sub-routine returning a TeardownResult
class IResource resource where Source #
A resource or sub-routine that can be transformed into a Teardown
operation
Cleanup main type and function
Sub-routine that performs a resource cleanup operation
data TeardownResult Source #
Result from a Teardown
sub-routine
BranchResult | Result is composed by multiple teardown sub-routines |
| |
LeafResult | Result represents a single teardown sub-routine |
| |
EmptyResult | Represents a stub cleanup operation (for lifting pure values) |
|
runTeardown :: HasTeardown t => t -> IO TeardownResult Source #
Executes all composed Teardown sub-routines safely, and returns a Tree data structure wich can be used to gather facts from the cleanup process.
runTeardown_ :: HasTeardown t => t -> IO () Source #
Executes all composed Teardown sub-routines safely.
Functions to create a Teardown
record
emptyTeardown :: Description -> Teardown Source #
Creates a stub Teardown sub-routine, normally used when a contract expects a teardown return but there is no allocation being made
Functions to deal with results from teardown
call
didTeardownFail :: TeardownResult -> Bool Source #
Returns a boolean indicating if any of the cleanup sub-routine failed
failedToredownCount :: TeardownResult -> Int Source #
Returns number of sub-routines that threw an exception on execution of teardown
toredownCount :: TeardownResult -> Int Source #
Returns number of sub-routines executed at teardown
prettyTeardownResult :: TeardownResult -> Doc Source #
Renders an ASCII Tree with the TeardownResult of a Teardown sub-routine execution