composed

package
v0.0.0-...-f0872cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StopAndForget   error
	StopWithRequeue error
)

Functions

func Handle

func Handle(err error, _ context.Context) (ctrl.Result, error)

func IsStopAndForget

func IsStopAndForget(err error) bool

func IsStopWithRequeue

func IsStopWithRequeue(err error) bool

func IsStopWithRequeueDelay

func IsStopWithRequeueDelay(err error) bool

func IsTerminal

func IsTerminal(err error) bool

func LoggerFromCtx

func LoggerFromCtx(ctx context.Context) logr.Logger

func LoggerIntoCtx

func LoggerIntoCtx(ctx context.Context, logger logr.Logger) context.Context

func StopAndForgetAction

func StopAndForgetAction(_ context.Context, _ State) (error, context.Context)

func StopWithRequeueAction

func StopWithRequeueAction(_ context.Context, _ State) (error, context.Context)

func StopWithRequeueDelay

func StopWithRequeueDelay(d time.Duration) error

Types

type Action

type Action func(ctx context.Context, state State) (error, context.Context)

func BuildBranchingAction

func BuildBranchingAction(name string, predicate Predicate, trueAction Action, falseAction Action) Action

func BuildSwitchAction

func BuildSwitchAction(name string, defaultAction Action, cases ...Case) Action

func ComposeActions

func ComposeActions(name string, actions ...Action) Action

func StopWithRequeueDelayAction

func StopWithRequeueDelayAction(d time.Duration) Action

type Case

type Case interface {
	Predicate(ctx context.Context, state State) bool
	Action(ctx context.Context, state State) (error, context.Context)
}

func NewCase

func NewCase(p Predicate, a Action) Case

type CaseStruct

type CaseStruct struct {
	P Predicate
	A Action
}

func (*CaseStruct) Action

func (cs *CaseStruct) Action(ctx context.Context, state State) (error, context.Context)

func (*CaseStruct) Predicate

func (cs *CaseStruct) Predicate(ctx context.Context, state State) bool

type Predicate

type Predicate func(ctx context.Context, state State) bool

func All

func All(predicates ...Predicate) Predicate

func Any

func Any(predicates ...Predicate) Predicate

func Not

func Not(p Predicate) Predicate

type State

type State interface {
	Client() client.Client
	EventRecorder() record.EventRecorder
	Name() types.NamespacedName
	Obj() client.Object

	LoadObj(ctx context.Context, opts ...client.GetOption) error
	UpdateObj(ctx context.Context, opts ...client.UpdateOption) error
	UpdateObjStatus(ctx context.Context, opts ...client.SubResourceUpdateOption) error
}

func NewState

func NewState(
	client client.Client,
	eventRecorder record.EventRecorder,
	name types.NamespacedName,
	obj client.Object,
) State

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL