actions

package
v0.0.56 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 13 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 InitActionTracker

func InitActionTracker(group string)

func Load

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

Load function, *T must satisfy Action

func RegisterFactory

func RegisterFactory(typeName string, factory FactoryFunc)

func Run

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

func Validate

func Validate(ctx 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
}

func NewActionTracker

func NewActionTracker(group string) *ActionTracker

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 Config

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

type FactoryFunc

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

func Wrap

func Wrap[T Action]() FactoryFunc

Wrap function with a constraint that *T satisfies Action

Jump to

Keyboard shortcuts

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