action

package
v0.5.7-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: BSD-3-Clause Imports: 4 Imported by: 94

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Actions deprecated

func Actions() map[string]Action

Deprecated: No longer used

func Factories

func Factories() map[string]Factory

func Register deprecated

func Register(id string, act Action) error

Deprecated: No longer used

func RegisterFactory

func RegisterFactory(ref string, 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() *data.IOMetadata
}

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

func Get deprecated

func Get(id string) Action

Deprecated: No longer used

type AsyncAction

type AsyncAction interface {
	Action

	// Run this Action
	Run(context context.Context, inputs map[string]*data.Attribute, 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"`
	Settings map[string]interface{} `json:"settings"`
	Data     json.RawMessage        `json:"data"`

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

	// Deprecated: No longer used
	Metadata *data.IOMetadata `json:"metadata"`
}

Config is the configuration for the Action

type Factory

type Factory interface {

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

Factory is used to create new instances for an action

func GetFactory

func GetFactory(ref string) Factory

type Metadata

type Metadata struct {
	ID       string `json:"ref"`
	Version  string
	Settings map[string]*data.Attribute
	Input    map[string]*data.Attribute
	Output   map[string]*data.Attribute

	Async    bool `json:"async"`
	Passthru bool `json:"passthru"`
}

Metadata is the metadata for the Activity

func GetMetadata

func GetMetadata(act Action) *Metadata

GetMetadata method to ensure we have metadata, remove in future

func NewMetadata

func NewMetadata(jsonMetadata string) *Metadata

NewMetadata creates the metadata object from its json representation

func (*Metadata) UnmarshalJSON added in v0.5.6

func (md *Metadata) UnmarshalJSON(b []byte) error

UnmarshalJSON overrides the default UnmarshalJSON for TaskEnv

type ResultHandler

type ResultHandler interface {

	// HandleResult is invoked when there are results available
	HandleResult(results map[string]*data.Attribute, err error)

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

ResultHandler used to handle results from the Action

type Runner

type Runner interface {
	// Deprecated: Use Execute() instead
	Run(context context.Context, act Action, uri string, options interface{}) (code int, data interface{}, err error)

	// Deprecated: Use Execute() instead
	RunAction(ctx context.Context, act Action, options map[string]interface{}) (results map[string]*data.Attribute, err error)

	// Execute the specified Action
	Execute(ctx context.Context, act Action, inputs map[string]*data.Attribute) (results map[string]*data.Attribute, err error)
}

Runner runs actions

type SyncAction

type SyncAction interface {
	Action

	// Run this Action
	Run(context context.Context, inputs map[string]*data.Attribute) (map[string]*data.Attribute, 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