action

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: BSD-3-Clause Imports: 9 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factories

func Factories() map[string]Factory

func LegacyRegister

func LegacyRegister(ref string, f Factory) error

DEPRECATED

func Register

func Register(action Action, f Factory) error

Types

type Action

type Action interface {

	// Metadata get the Action's metadata
	Metadata() *Metadata

	// IOMetadata get the Action's IO metadata
	IOMetadata() *metadata.IOMetadata
}

Action is an action to perform as a result of a trigger

type AsyncAction

type AsyncAction interface {
	Action

	// Run this Action
	Run(ctx context.Context, input map[string]interface{}, handler ResultHandler) error
}

AsyncAction is an asynchronous action to perform as a result of a trigger, the action can asynchronously return results as it runs. It returns immediately, but will continue to run.

type Config

type Config struct {
	//inline action
	Ref      string                 `json:"ref,omitempty"`
	Settings map[string]interface{} `json:"settings,omitempty"`

	//referenced action
	Id string `json:"id,omitempty"`

	//DEPRECATED
	Type string `json:"type,omitempty"`
}

Config is the configuration for the Action

type Descriptor

type Descriptor struct {
	ID      string `json:"ref"`
	Version string `json:"version"`
}

Descriptor is the descriptor for the Action

type Factory

type Factory interface {

	// Initialize is called to initialize the action factory
	Initialize(ctx InitContext) error

	// New create a new Action
	New(config *Config) (Action, error)
}

Factory s used to create new instances for an action

func GetFactory

func GetFactory(ref string) Factory

type Info

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

func NewInfo

func NewInfo(async bool, passthru bool) *Info

func (*Info) Async

func (i *Info) Async() bool

func (*Info) Id

func (i *Info) Id() string

func (*Info) Passthru

func (i *Info) Passthru() bool

type InitContext

type InitContext interface {

	// ResourceManager gets the resource manager for the app
	ResourceManager() *resource.Manager

	// ResourceManager gets the service manager for the engine
	ServiceManager() *service.Manager

	// RuntimeSettings are any runtime setting provided to the engine
	RuntimeSettings() map[string]interface{}
}

InitContext is the initialization context for the action factory

type Metadata

type Metadata struct {
	*metadata.IOMetadata
	Settings map[string]data.TypedValue
}

func ToMetadata

func ToMetadata(mdStructs ...interface{}) *Metadata

func (*Metadata) MarshalJSON

func (md *Metadata) MarshalJSON() ([]byte, error)

type ResultHandler

type ResultHandler interface {

	// HandleResult is invoked when there are results available
	HandleResult(results map[string]interface{}, err error)

	// Done indicates that the action has completed
	Done()
}

ResultHandler used to handle results from the Action

type Runner

type Runner interface {

	// RunAction the specified Action
	RunAction(ctx context.Context, act Action, input map[string]interface{}) (results map[string]interface{}, err error)
}

Runner runs actions

type SyncAction

type SyncAction interface {
	Action

	// Run this Action
	Run(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error)
}

SyncAction is a synchronous action to perform as a result of a trigger

Jump to

Keyboard shortcuts

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