resource

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MissingHandlerResourcesErr = errors.New("missing handler resources, cannot perform handling")
	OperationNotReadyErr       = errors.New("operation not ready yet")
)

Functions

This section is empty.

Types

type ExecuteResult

type ExecuteResult struct {
	// contains filtered or unexported fields
}

ExecuteResult defines a wrapper for multiple Operations performed by Executor.Execute.

func (ExecuteResult) Add

Add adds a successful Operation to ExecuteResult

func (ExecuteResult) AddWithErr

func (r ExecuteResult) AddWithErr(op Operation, err error) ExecuteResult

AddWithErr adds a failed Operation with its error to ExecuteResult

func (ExecuteResult) Error

func (r ExecuteResult) Error() error

Error returns the errored operation

func (ExecuteResult) Errored

func (r ExecuteResult) Errored() bool

func (ExecuteResult) Name

func (r ExecuteResult) Name() string

func (ExecuteResult) NotReady

func (r ExecuteResult) NotReady() bool

func (ExecuteResult) Object

func (r ExecuteResult) Object() client.Object

func (ExecuteResult) ProcessingOps

func (r ExecuteResult) ProcessingOps() []string

ProcessingOps returns processing operations performed.

func (ExecuteResult) Ready

func (r ExecuteResult) Ready() bool

func (ExecuteResult) Skipped

func (r ExecuteResult) Skipped() bool

type Executor

type Executor[T client.Object] struct {
	Name       string
	FetchFunc  func(ctx context.Context, obj T) error
	CreateFunc func(ctx context.Context, obj T) error
	UpdateFunc func(ctx context.Context, obj T) (bool, error)
	IsReady    func(ctx context.Context, obj T) bool
	// contains filtered or unexported fields
}

Executor simplifies synchronization logic for a requested resource. It exposes a simple Execute method which processes resource lifecycle.

func NopExecutor

func NopExecutor[T client.Object](name string) Executor[T]

NopExecutor is noop executor for workflows. It can be used to indicate that requested operation is valid, but nothing to execute.

func (*Executor[T]) Execute

func (h *Executor[T]) Execute(ctx context.Context, obj T) ExecuteResult

Execute performs the resource execution by invoking Executor functions in ordered manner. Returns an error if data is missing or for runtime operations. Returns all the operations performed during execution.

type Operation

type Operation int
const (
	Skip Operation = 1 << iota
	Fetch
	Create
	Update
	Check
)

func (Operation) String

func (o Operation) String() string

Jump to

Keyboard shortcuts

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