actions

package
v0.0.0-...-c4eff38 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActionsArr = map[string]Action{
	"advance":     &Advance{},
	"callback":    &Callback{},
	"cbsplit":     &CbSplit{},
	"cbfinish":    &CbFinish{},
	"conditional": &Conditional{},
	"log":         &Log{},
	"match":       &Match{},
	"math":        &Math{},
	"set":         &Set{},
	"wait":        &Wait{},
	"test":        &Test{},
	"url":         &URL{},
}

Functions

func EqualJSON

func EqualJSON(input string, expected string) (bool, interface{}, error)

EqualJSON returns a boolean value for JSON comparison, as well as error.

func EqualStrings

func EqualStrings(input string, expected string) (bool, interface{}, error)

EqualStrings returns a boolean value for string comparison, as well as error.

func EqualYAML

func EqualYAML(input string, expected string) (bool, interface{}, error)

EqualYAML returns a boolean value for YAML comparison, as well as error.

func Execute

func Execute(t string, a map[string]interface{}, p *plan.Plan) (Action, ExecuteResult)

DoAction executes the respective action requested, executing callbacks, advancing, waiting, or resetting as needed.

func ExecuteComparison

func ExecuteComparison(p *plan.Plan, data string, path string, strbody string, f func(string, string) (bool, interface{}, error)) (interface{}, error)

ExecuteComparison compares return body string and OnExpected value for a State's transaction.

func IfaceToFloat

func IfaceToFloat(i interface{}) (float64, error)

func LoadJSON

func LoadJSON(in string) (interface{}, error)

LoadJSON unmarshals JSON into an interface and returns the interface.

func LoadString

func LoadString(in string) (interface{}, error)

LoadString just returns a string.

func LoadYAML

func LoadYAML(in string) (interface{}, error)

LoadYAML unmarshals YAML/YML into an interface and returns the interface.

func MatchingInterfaces

func MatchingInterfaces(mFile interface{}, candidate interface{}) bool

MatchingInterfaces identifies if interface types and interface contents match.

func ParseStringTemplate

func ParseStringTemplate(p *plan.Plan, in string) string

func ParseTemplate

func ParseTemplate(p *plan.Plan, args map[string]interface{}) (map[string]interface{}, error)

func Satisfy

func Satisfy(t string, a map[string]interface{}) (bool, error)

func SetLogger

func SetLogger(t string)

Types

type Action

type Action interface {
	Execute(*plan.Plan) ExecuteResult
	Abort()
	GetName() string
	SetArgs(map[string]interface{})
	Satisfy() (bool, error)
	GetContext() (*context.Context, *context.CancelFunc)
	CanBackground() bool
	IsBackgrounded() bool
}

implementation note: Satisfy is implemented across all actions, but it only makes sense in some. Actions that do not have an internal state do not make sense to advance, as there is nothing that will allow us to determine whether a condition is satisfied.

type Actions

type Actions struct {
	Actions map[string]Action
}

func NewActions

func NewActions() *Actions

type Advance

type Advance struct {
	Action
	Args ArgStruct
}

func (*Advance) Abort

func (a *Advance) Abort()

func (*Advance) CanBackground

func (a *Advance) CanBackground() bool

func (*Advance) Execute

func (a *Advance) Execute(p *plan.Plan) (r ExecuteResult)

func (*Advance) GetContext

func (a *Advance) GetContext() (*context.Context, *context.CancelFunc)

func (*Advance) GetName

func (a *Advance) GetName() string

func (*Advance) IsBackgrounded

func (a *Advance) IsBackgrounded() bool

func (*Advance) Satisfy

func (a *Advance) Satisfy() (bool, error)

func (*Advance) SetArgs

func (a *Advance) SetArgs(i map[string]interface{})

type ArgStruct

type ArgStruct struct {
	Args map[string]interface{}
}

func (*ArgStruct) GetArg

func (a *ArgStruct) GetArg(n string, t reflect.Type, required bool) (interface{}, error)

func (*ArgStruct) SetArg

func (a *ArgStruct) SetArg(n string, i interface{}) error

type Callback

type Callback struct {
	Action
	Args ArgStruct
	// contains filtered or unexported fields
}

func (*Callback) Abort

func (c *Callback) Abort()

func (*Callback) CanBackground

func (c *Callback) CanBackground() bool

func (*Callback) Execute

func (c *Callback) Execute(p *plan.Plan) (r ExecuteResult)

func (*Callback) GetContext

func (c *Callback) GetContext() (*context.Context, *context.CancelFunc)

func (*Callback) GetName

func (c *Callback) GetName() string

func (*Callback) IsBackgrounded

func (c *Callback) IsBackgrounded() bool

func (*Callback) Satisfy

func (c *Callback) Satisfy() (bool, error)

func (*Callback) SetArgs

func (c *Callback) SetArgs(i map[string]interface{})

type CbFinish

type CbFinish struct {
	Action
	Args ArgStruct
}

func (*CbFinish) Abort

func (c *CbFinish) Abort()

func (*CbFinish) CanBackground

func (c *CbFinish) CanBackground() bool

func (*CbFinish) Execute

func (c *CbFinish) Execute(p *plan.Plan) (r ExecuteResult)

func (*CbFinish) GetContext

func (c *CbFinish) GetContext() (*context.Context, *context.CancelFunc)

func (*CbFinish) GetName

func (c *CbFinish) GetName() string

func (*CbFinish) IsBackgrounded

func (c *CbFinish) IsBackgrounded() bool

func (*CbFinish) Satisfy

func (c *CbFinish) Satisfy() (bool, error)

func (*CbFinish) SetArgs

func (c *CbFinish) SetArgs(i map[string]interface{})

type CbSplit

type CbSplit struct {
	Action
	Args ArgStruct
	// contains filtered or unexported fields
}

func (*CbSplit) Abort

func (c *CbSplit) Abort()

func (*CbSplit) CanBackground

func (c *CbSplit) CanBackground() bool

func (*CbSplit) Execute

func (c *CbSplit) Execute(p *plan.Plan) (r ExecuteResult)

func (*CbSplit) GetContext

func (c *CbSplit) GetContext() (*context.Context, *context.CancelFunc)

func (*CbSplit) GetName

func (c *CbSplit) GetName() string

func (*CbSplit) IsBackgrounded

func (c *CbSplit) IsBackgrounded() bool

func (*CbSplit) Satisfy

func (c *CbSplit) Satisfy() (bool, error)

func (*CbSplit) SetArgs

func (c *CbSplit) SetArgs(i map[string]interface{})

type Conditional

type Conditional struct {
	Action
	Args ArgStruct
}

func (*Conditional) Abort

func (c *Conditional) Abort()

func (*Conditional) CanBackground

func (c *Conditional) CanBackground() bool

func (*Conditional) Execute

func (c *Conditional) Execute(p *plan.Plan) (r ExecuteResult)

func (*Conditional) GetContext

func (c *Conditional) GetContext() (*context.Context, *context.CancelFunc)

func (*Conditional) GetName

func (c *Conditional) GetName() string

func (*Conditional) IsBackgrounded

func (c *Conditional) IsBackgrounded() bool

func (*Conditional) Satisfy

func (c *Conditional) Satisfy() (bool, error)

func (*Conditional) SetArgs

func (c *Conditional) SetArgs(i map[string]interface{})

type ConditionalOps

type ConditionalOps struct {
	LeftOp  interface{}
	RightOp interface{}
	// contains filtered or unexported fields
}

func NewConditionalOps

func NewConditionalOps() *ConditionalOps

func (*ConditionalOps) Compare

func (c *ConditionalOps) Compare(op string) (bool, error)

func (*ConditionalOps) CompareEq

func (c *ConditionalOps) CompareEq() (bool, error)

func (*ConditionalOps) CompareGe

func (c *ConditionalOps) CompareGe() (bool, error)

func (*ConditionalOps) CompareGt

func (c *ConditionalOps) CompareGt() (bool, error)

func (*ConditionalOps) CompareLe

func (c *ConditionalOps) CompareLe() (bool, error)

func (*ConditionalOps) CompareLt

func (c *ConditionalOps) CompareLt() (bool, error)

func (*ConditionalOps) CompareNe

func (c *ConditionalOps) CompareNe() (bool, error)

func (*ConditionalOps) ConvertToFloat64

func (c *ConditionalOps) ConvertToFloat64() (float64, float64, error)

type ExecuteResult

type ExecuteResult struct {
	Err          error
	Complete     bool
	Success      bool
	Advance      bool
	NewTxn       string
	RegisterURL  string
	RegisterUUID uuid.UUID
}

func DoCallback

func DoCallback(a ArgStruct, p *plan.Plan, ctx context.Context) (r ExecuteResult)

type Log

type Log struct {
	Action
	Args         ArgStruct
	DefaultLevel string
}

func (*Log) Abort

func (l *Log) Abort()

func (*Log) CanBackground

func (l *Log) CanBackground() bool

func (*Log) Execute

func (l *Log) Execute(p *plan.Plan) (r ExecuteResult)

func (*Log) GetContext

func (l *Log) GetContext() (*context.Context, *context.CancelFunc)

func (*Log) GetName

func (l *Log) GetName() string

func (*Log) IsBackgrounded

func (l *Log) IsBackgrounded() bool

func (*Log) Satisfy

func (l *Log) Satisfy() (bool, error)

func (*Log) SetArgs

func (l *Log) SetArgs(i map[string]interface{})

type Match

type Match struct {
	Action
	Args ArgStruct
}

func (*Match) Abort

func (m *Match) Abort()

func (*Match) CanBackground

func (m *Match) CanBackground() bool

func (*Match) Execute

func (m *Match) Execute(p *plan.Plan) (r ExecuteResult)

func (*Match) GetContext

func (m *Match) GetContext() (*context.Context, *context.CancelFunc)

func (*Match) GetName

func (m *Match) GetName() string

func (*Match) IsBackgrounded

func (m *Match) IsBackgrounded() bool

func (*Match) LoadFile

func (m *Match) LoadFile(n string, t string) (interface{}, error)

func (*Match) LoadString

func (m *Match) LoadString(b string, t string) (interface{}, error)

func (*Match) Satisfy

func (m *Match) Satisfy() (bool, error)

func (*Match) SetArgs

func (m *Match) SetArgs(i map[string]interface{})

type Math

type Math struct {
	Action
	Args ArgStruct
}

func (*Math) Abort

func (w *Math) Abort()

func (*Math) CanBackground

func (m *Math) CanBackground() bool

func (*Math) Execute

func (w *Math) Execute(p *plan.Plan) (r ExecuteResult)

func (*Math) GetContext

func (m *Math) GetContext() (*context.Context, *context.CancelFunc)

func (*Math) GetName

func (w *Math) GetName() string

func (*Math) IsBackgrounded

func (m *Math) IsBackgrounded() bool

func (*Math) Satisfy

func (m *Math) Satisfy() (bool, error)

func (*Math) SetArgs

func (m *Math) SetArgs(i map[string]interface{})

type MathOps

type MathOps struct {
	LeftOp  interface{}
	RightOp interface{}
	// contains filtered or unexported fields
}

func (*MathOps) Execute

func (c *MathOps) Execute(op string) (float64, error)

type QueueContext

type QueueContext struct {
	Ctx      *gin.Context
	Finished chan bool
}

type Set

type Set struct {
	Action
	Args ArgStruct
}

func (*Set) Abort

func (s *Set) Abort()

func (*Set) CanBackground

func (s *Set) CanBackground() bool

func (*Set) Execute

func (s *Set) Execute(p *plan.Plan) (r ExecuteResult)

func (*Set) GetContext

func (s *Set) GetContext() (*context.Context, *context.CancelFunc)

func (*Set) GetName

func (s *Set) GetName() string

func (*Set) IsBackgrounded

func (s *Set) IsBackgrounded() bool

func (*Set) Satisfy

func (s *Set) Satisfy() (bool, error)

func (*Set) SetArgs

func (s *Set) SetArgs(i map[string]interface{})

type Test

type Test struct {
	Action
	Args  ArgStruct
	Reset bool
}

func (*Test) Abort

func (t *Test) Abort()

func (*Test) Execute

func (t *Test) Execute(p *plan.Plan) (r ExecuteResult)

This is a no-op solely for testing.

func (*Test) GetContext

func (a *Test) GetContext() (*context.Context, *context.CancelFunc)

func (*Test) GetName

func (t *Test) GetName() string

func (*Test) SetArgs

func (t *Test) SetArgs(i map[string]interface{})

type URL

type URL struct {
	Action
	Args       ArgStruct
	Registered bool
	// contains filtered or unexported fields
}

func (*URL) Abort

func (u *URL) Abort()

func (*URL) CanBackground

func (u *URL) CanBackground() bool

func (*URL) Execute

func (u *URL) Execute(p *plan.Plan) (r ExecuteResult)

func (*URL) GetContext

func (u *URL) GetContext() (*context.Context, *context.CancelFunc)

func (*URL) GetName

func (u *URL) GetName() string

func (*URL) IsBackgrounded

func (u *URL) IsBackgrounded() bool

func (*URL) Satisfy

func (u *URL) Satisfy() (bool, error)

func (*URL) SetArgs

func (u *URL) SetArgs(i map[string]interface{})

func (*URL) URLMatches

func (u *URL) URLMatches(ctx *QueueContext) (bool, error)

type Wait

type Wait struct {
	Action
	Args         ArgStruct
	Reset        bool
	CurrentTimer int
}

func (*Wait) Abort

func (w *Wait) Abort()

func (*Wait) CanBackground

func (w *Wait) CanBackground() bool

func (*Wait) Execute

func (w *Wait) Execute(p *plan.Plan) (r ExecuteResult)

func (*Wait) GetContext

func (w *Wait) GetContext() (*context.Context, *context.CancelFunc)

func (*Wait) GetName

func (w *Wait) GetName() string

func (*Wait) IsBackgrounded

func (w *Wait) IsBackgrounded() bool

func (*Wait) Satisfy

func (w *Wait) Satisfy() (bool, error)

func (*Wait) SetArgs

func (w *Wait) SetArgs(i map[string]interface{})

Jump to

Keyboard shortcuts

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