actions

package
v0.1.88 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As[T any](t any) (*T, error)

func Load

func Load[T Action](content []byte) (*T, error)

Load function, *T must satisfy Action

func RegisterBuilder added in v0.1.20

func RegisterBuilder(typeName string, builder BuilderFunc)

func Run

func Run(ctx context.Context, action Action) (any, error)

func SetActionTracker added in v0.0.61

func SetActionTracker(actionTracker *ActionTracker)

func Validate

func Validate(_ context.Context, input proto.Message) error

Validate action input

Types

type Action

type Action interface {
	Run(ctx context.Context) (any, error)
	Command() string
}

func CreateAction

func CreateAction(content []byte) (Action, error)

type ActionSave

type ActionSave struct {
	Command string          `json:"command"`
	Data    json.RawMessage `json:"data"`
}

type ActionStep

type ActionStep struct {
	Step   int
	Data   *json.RawMessage `json:"data"`
	Action Action
}

type ActionTracker

type ActionTracker struct {
	Dir    string
	Replay bool
}

func NewActionTracker

func NewActionTracker(ctx context.Context, group string) (*ActionTracker, error)

func (*ActionTracker) GetActions

func (tracker *ActionTracker) GetActions(_ context.Context) ([]Action, error)

func (*ActionTracker) NextStep

func (tracker *ActionTracker) NextStep() int

func (*ActionTracker) Save

func (tracker *ActionTracker) Save(action Action) error

func (*ActionTracker) WithDir added in v0.0.52

func (tracker *ActionTracker) WithDir(dir string)

type BuilderFunc added in v0.1.20

type BuilderFunc func(content []byte) (Action, error)

func Wrap

func Wrap[T Action]() BuilderFunc

Wrap function with a constraint that *T satisfies Action

type Config

type Config struct {
	Kind string `json:"kind"`
}

Jump to

Keyboard shortcuts

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