Documentation ¶
Overview ¶
Package predicate provides functions that wrap existing actions but executes them only on conditions ("predicates"). If a predicate evaluates to false, the wrapped action is not called and skips the step in the pipeline, indicating success.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func If ¶ added in v0.11.0
If returns a new step that wraps the given step and executes its action only if the given Predicate evaluates true. The pipeline.Context from the pipeline is passed through the given action.
func ToNestedStep ¶
ToNestedStep wraps the given pipeline in its own step. When the step's function is called, the given Predicate will evaluate whether the nested pipeline.Pipeline should actually run. It returns the pipeline's pipeline.Result, otherwise an empty (successful) pipeline.Result struct. The given pipeline has to define its own pipeline.Context, it's not passed "down".
func ToStep ¶
ToStep wraps the given action func in its own step. When the step's function is called, the given Predicate will evaluate whether the action should actually run. It returns the action's pipeline.Result, otherwise an empty (successful) pipeline.Result struct. The pipeline.Context from the pipeline is passed through the given action.
Types ¶
type Predicate ¶
Predicate is a function that expects 'true' if a pipeline.ActionFunc should run. It is evaluated lazily resp. only when needed.
func And ¶
And returns a Predicate that does logical AND of the given predicates. p2 is not evaluated if p1 evaluates already to false.
func Bool ¶
Bool returns a Predicate that simply returns v when evaluated. Use BoolPtr() over Bool() if the value can change between setting up the pipeline and evaluating the predicate.
func BoolPtr ¶ added in v0.12.0
BoolPtr returns a Predicate that returns *v when evaluated. Use BoolPtr() over Bool() if the value can change between setting up the pipeline and evaluating the predicate.