utils

package
v0.0.0-...-e7c744b Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(slice []string, s string) bool

Contains checks slice contains `s` string

func EncodeStringToBase64

func EncodeStringToBase64(s string) string

EncodeStringToBase64 first checks if the string is encoded if yes returns it if no than encodes it.

Types

type Action

type Action interface {
	GetName() string
	ExecuteAction(input interface{}) (output interface{}, err error)
}

Action is a named function which can be executed

type ActionCallContext

type ActionCallContext struct {
	Action           Action
	RemainingActions []Action
	Input            interface{}
	TryToUndo        bool
}

ActionCallContext is context in which Actions can be executed

func NewActionCallContext

func NewActionCallContext(action Action, remainingActions []Action, input interface{}, tryToUndoOnFail bool) *ActionCallContext

NewActionCallContext creates a new ActionCallContext

func (*ActionCallContext) OnCompleted

func (ctx *ActionCallContext) OnCompleted(output interface{}) (interface{}, error)

OnCompleted is called back when an action has completed

func (*ActionCallContext) OnFailed

func (ctx *ActionCallContext) OnFailed(error error)

OnFailed is called back when an action has failed

type ActionExecutor

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

ActionExecutor executes Actions

func NewActionExecutor

func NewActionExecutor(log logrus.FieldLogger) *ActionExecutor

NewActionExecutor creates a new ActionExecutor

func (*ActionExecutor) ExecuteActions

func (ae *ActionExecutor) ExecuteActions(actions []Action, input interface{}, tryToUndoOnFail bool) (output interface{}, err error)

ExecuteActions executes the defined Actions

type RevocableAction

type RevocableAction interface {
	Action
	UndoAction() (err error)
}

RevocableAction is an Action which can be revoked

Jump to

Keyboard shortcuts

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