Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckEnsurer ¶
CheckEnsurer is an etension of ensurer, which also provides an Is function to check the state of the resource.
type Enforced ¶
type Enforced func() bool
Enforced checks if state is already enforced in the environment. When it is, it must return true.
type Ensurer ¶
type Ensurer interface { // Ensure will modify the environment so that it represents the wanted // state. Ensure() error }
State represents a wanted state that should be pushed to the environment.
func WithCheck ¶
func WithCheck(en CheckEnsurer) Ensurer
WithCheck creates an Ensurer instance that runs is before Ensure.
type Runner ¶
type Runner struct { // Is is checked before enforcing all states. // The states will not be enforced when the function is returning true. Is Enforced // Parallel defines if the states are ensured in parallel. There is no // dependency management at work. The requirements must already be met // beforehand. // When parallel is set to true the processing will not be halted on the // first error. Instead all errors will be collected and returned. Parallel bool // States is the list of states to ensure when Ensure() is called. States []Ensurer // When parallel mode is used, the number of threads to spawn can be set. // When not set, every state will spawn a thread. Workers int }
Runner takes a list of ensurers and enforces their state. The runner is not transactional.
func (*Runner) Ensure ¶
Ensure will call Ensure() on every state. When Parallel is true, all states will be ensured in parallel. The number of threads that will be spawned can be controlled by the Workers attribute. In case of an error the processing will be aborted. When Parallel is true all errors are collected and returned as one and the processing will not be halted.