machine

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(ctx context.Context, info *ReconcileInfo, instance interface{}) (StateType, ctrl.Result, error)

Handler is a state handle function. If an error isn't nil or ctrl.Result.Requeue is true the state machine will requeue the Request again

type Instance

type Instance interface {
	runtime.Object
	GetState() StateType
	SetState(state StateType)
	SetError(err error)
}

Instance is a object for the CR need be reconcile NOTE: Instance must be a pointer

type Machine

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

Machine is a state machine

func New

func New(info *ReconcileInfo, instance Instance, handlers map[StateType]Handler) Machine

New a state machine NOTE: The paramater of instance must be a pointer

func (*Machine) Reconcile

func (m *Machine) Reconcile(ctx context.Context) (bool, ctrl.Result, error)

Reconcile state machine. If dirty is true, it means the instance has changed

type ReconcileInfo

type ReconcileInfo struct {
	Client client.Client
	Logger logr.Logger
}

ReconcileInfo is the information need by reconcile

type StateType

type StateType string

StateType is the type of .status.state

Jump to

Keyboard shortcuts

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