Documentation ¶
Index ¶
- Variables
- func Exit() (ctrl.Result, error)
- func ExitIf(cond bool) (ctrl.Result, error)
- func IgnoreExit(r ctrl.Result, err error) (ctrl.Result, error)
- func NeedsRequeue(result ctrl.Result, err error) bool
- func NoRequeue() (ctrl.Result, error)
- func RequeueAfter(after time.Duration) (ctrl.Result, error)
- func RequeueIfError(err error) (ctrl.Result, error)
- func RequeueIfErrorAndWrap(explain string, err error) (ctrl.Result, error)
- func RequeueImmediately() (ctrl.Result, error)
- func ValidateOwnership(obj, owner client.Object) bool
- type Action
- func If(predicate bool, act Action) Action
- func Join(actions ...Action) Action
- func NewAction(description string, f ActionFunc) Action
- func OptimizeWorkflow(workflow Action) Action
- func OrderedJoin(actions ...Action) Action
- func Parallel(act Action) Action
- func ParallelJoin(actions ...Action) Action
- func Retry(limit int, act Action) Action
- func Sequential(actions ...Action) Action
- func Shared(inner Action) Action
- func Timeout(timeout time.Duration, act Action) Action
- type ActionFunc
- type ActionHook
- type ChainedActionHooks
Constants ¶
This section is empty.
Variables ¶
var Continue = NoRequeue
Continue is an alias of NoRequeue.
var ErrExit = errors.New("exit")
ErrExit exits the workflow early.
var Nop = &nopAction{}
Nop is a special action that does nothing.
var SequentialJoin = OrderedJoin
SequentialJoin is an alias of JoinOrdered, because it runs the actions in both join and sequential style. It is useful to use `SequentialJoin` to declare something that must run after something else. E.g., if B must run after A, but you want B to run no matter what A returns, you can use SequentialJoin(A, B) instead of Sequential(A, B).
Functions ¶
func IgnoreExit ¶
IgnoreExit keeps the result but returns a nil when err == ErrExit.
func NeedsRequeue ¶
NeedsRequeue reports if the result and error indicates a requeue.
func RequeueAfter ¶
RequeueAfter returns a result with requeue after set to the given duration and a nil.
func RequeueIfError ¶
RequeueIfError returns an empty result with the err.
func RequeueIfErrorAndWrap ¶
RequeueIfErrorAndWrap returns an empty result with a wrapped err.
func RequeueImmediately ¶
RequeueImmediately returns a result with requeue set to true and a nil.
func ValidateOwnership ¶
Types ¶
type Action ¶
Action is the basic unit to form a workflow. It represents some reaction to the states it observes. It is recommended to follow the Single-Responsibility-Rule while designing a Action.
func Join ¶
Join organizes the actions in a split-join flow, which doesn't guarantee the execution order.
func NewAction ¶
func NewAction(description string, f ActionFunc) Action
NewAction wraps the given description and function into an action.
func OptimizeWorkflow ¶
OptimizeWorkflow optimizes the workflow by eliminating unnecessary layers:
- Nop in Sequential or Join will be removed
- Empty Join and Sequential will be omitted
- Parallel in Sequential will be unwrapped
- Sequential and Join with single child will be simplified by removing them
- Sequential(Sequential) will be flattened
- Join(Join) will be flattened
- Parallel(Parallel) will be simplified with only one Parallel
- Timeout(Timeout) will be simplified with the tighter timeout
func OrderedJoin ¶
OrderedJoin organizes the actions in a split-join flow and guarantees the execution order.
func ParallelJoin ¶
ParallelJoin organizes the actions in a split-join flow and executes them in parallel.
func Retry ¶
Retry wraps an action into a retryable action. It reruns the action iff. there is a non-exit error.
func Sequential ¶
Sequential organizes the actions into a sequential flow.
type ActionHook ¶
type ActionHook interface { // PreRun is a hook that runs before the action. It's embedded by the ctrlkit-gen tool and should // be provided with an option. One can get the name and the states of the action from this hook. PreRun(ctx context.Context, logger logr.Logger, action string, states map[string]runtime.Object) // PostRun is a hook than runs after the action. It's embedded by the ctrlkit-gen tool. One can get // the result of the action from this hook. PostRun(ctx context.Context, logger logr.Logger, action string, result ctrl.Result, err error) }
ActionHook provides hooks for actions implementations in controller manager.
type ChainedActionHooks ¶
type ChainedActionHooks struct {
// contains filtered or unexported fields
}
ChainedActionHooks chains a sequence of hooks into one.
func ChainActionHooks ¶
func ChainActionHooks(hooks ...ActionHook) *ChainedActionHooks
ChainActionHooks creates a ChainedActionHooks with the given hooks.
func (*ChainedActionHooks) Add ¶
func (c *ChainedActionHooks) Add(hook ActionHook)
Add adds hook to this.