actions

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAction

func RegisterAction(action Action)

RegisterAction registers a new action if it does not exist.

func StartAction

func StartAction(logger zerolog.Logger, actionType ActionType, serverType definitions.ServerType)

StartAction starts actions based on type

func StartLimitedAction

func StartLimitedAction(logger zerolog.Logger, actionType ActionType, serverType definitions.ServerType, limit ActionTypes)

StartAction starts actions based on type if actionType is on the limit list

func StartPreStopActions

func StartPreStopActions(logger zerolog.Logger, serverType definitions.ServerType, progress Progressor)

StartPreStopActions runs registered pre stop actions.

Types

type Action

type Action interface {
	// Name returns name of the action.
	Name() string
	// Timeout returns how long it should wait for the action to be finished.
	Timeout() time.Duration
	// Condition returns true if this action should be launched.
	Condition(serverType definitions.ServerType) bool
}

Action describes how some actions should be started.

type ActionPreStop

type ActionPreStop interface {
	Action
	// PreStop runs action before server is stopped.
	PreStop(ctx context.Context, progress Progressor) error
}

ActionPreStop describes how pre stop actions should be started.

type ActionType

type ActionType string

ActionType keeps type of action

const (
	// ActionTypeAll filter which run all action types
	ActionTypeAll ActionType = "All"
	// ActionTypePreStop PreStop Action Type
	ActionTypePreStop ActionType = "PreStop"
)

func (ActionType) String

func (a ActionType) String() string

String returns string value of ActionType

type ActionTypes

type ActionTypes []ActionType

ActionTypes is the list of ActionType

func (ActionTypes) Contains

func (a ActionTypes) Contains(t ActionType) bool

Contains returns true if requested action is on list

type ProgressEmpty

type ProgressEmpty struct{}

ProgressEmpty describes empty progress for the actions.

func (ProgressEmpty) Failed

func (p ProgressEmpty) Failed(_ error)

Failed is launched when the action fails.

func (ProgressEmpty) Finished

func (p ProgressEmpty) Finished()

Finished is launched when the action finishes.

func (ProgressEmpty) Progress

func (p ProgressEmpty) Progress(message string) error

Progress is launched whenever some progress occurs for the specific action.

func (ProgressEmpty) Started

func (p ProgressEmpty) Started(_ string)

Started is launched when the action starts.

type ProgressLog

type ProgressLog struct {
	LoggerOriginal zerolog.Logger
	// contains filtered or unexported fields
}

ProgressLog describes simple logger for actions.

func (*ProgressLog) Failed

func (p *ProgressLog) Failed(err error)

Failed is launched when the action fails.

func (*ProgressLog) Finished

func (p *ProgressLog) Finished()

Finished is launched when the action finishes.

func (*ProgressLog) Progress

func (p *ProgressLog) Progress(message string) error

Progress is launched whenever some progress occurs for the specific action.

func (*ProgressLog) Started

func (p *ProgressLog) Started(actionName string)

Started is launched when the action starts.

type Progressor

type Progressor interface {
	// Started is launched when the action starts.
	Started(actionName string)
	// Failed is launched when the action fails.
	Failed(err error)
	// Finished is launched when the action finishes.
	Finished()
	// Progress is launched whenever some progress occurs for the specific action.
	Progress(message string) error
}

Progressor describes what to do when the specific moment of action occurs.

type Registry added in v0.17.1

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

Registry allows to register new actions.

func (*Registry) GetActions added in v0.17.1

func (r *Registry) GetActions() map[string]Action

GetActions returns actions which are already registered.

Jump to

Keyboard shortcuts

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