activity

package
v0.5.7-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2018 License: BSD-3-Clause Imports: 5 Imported by: 634

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(activity Activity)

Register registers the specified activity

func RegisterFactory added in v0.5.7

func RegisterFactory(ref string, f Factory) error

Types

type Activity

type Activity interface {

	// Eval is called when an Activity is being evaluated.  Returning true indicates
	// that the task is done.
	Eval(ctx Context) (done bool, err error)

	// Metadata returns the metadata of the activity
	Metadata() *Metadata
}

Activity is an interface for defining a custom Activity Execution

func Activities

func Activities() []Activity

Activities gets all the registered activities

func Get

func Get(id string) Activity

Get gets specified activity

type AsyncActivity

type AsyncActivity interface {
	Activity

	// PostEval is called when a activity that didn't complete during the Eval
	// needs to be notified.  Returning true indicates that the activity is done.
	PostEval(context Context, userData interface{}) (done bool, err error)
}

AsyncActivity is an interface for defining a custom Task that supports asynchronous callback

type Config added in v0.5.7

type Config struct {
	Ref         string                 `json:"ref"`
	Settings    map[string]interface{} `json:"settings,omitempty"`
	InputAttrs  map[string]interface{} `json:"input,omitempty"`
	OutputAttrs map[string]interface{} `json:"output,omitempty"`
}

func (*Config) FixUp added in v0.5.7

func (c *Config) FixUp(metadata *Metadata)

type Context

type Context interface {

	// ActivityHost gets the "host" under with the activity is executing
	ActivityHost() Host

	//Name the name of the activity that is currently executing
	Name() string

	// GetInput gets the value of the specified input attribute
	GetInput(name string) interface{}

	// GetOutput gets the value of the specified output attribute
	GetOutput(name string) interface{}

	// SetOutput sets the value of the specified output attribute
	SetOutput(name string, value interface{})

	// GetSetting gets the value of the specified setting
	// Deprecated
	GetSetting(setting string) (value interface{}, exists bool)

	// GetInitValue gets the specified initialization value
	// Deprecated
	GetInitValue(key string) (value interface{}, exists bool)

	// Deprecated: Use ActivityHost().Name() instead.
	TaskName() string

	// Deprecated: Use ActivityHost() instead.
	FlowDetails() FlowDetails
}

Context describes the execution context for an Activity. It provides access to attributes, task and Flow information.

type DynamicIO

type DynamicIO interface {

	// IOMetadata get the input/output metadata
	IOMetadata(ctx Context) (*data.IOMetadata, error)
}

DynamicIO is an optional interface that can be implemented by an activity. If implemented, IOMetadata() will be invoked to determine the inputs/outputs of the activity instead of relying on the static information from the Activity's Metadata

type Error

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

Error is an activity error

func NewError

func NewError(errorText string, code string, errorData interface{}) *Error

func (*Error) ActivityName

func (e *Error) ActivityName() string

ActivityName the activity name

func (*Error) Code

func (e *Error) Code() string

Code returns any associated error code

func (*Error) Data

func (e *Error) Data() interface{}

Data returns any associated error data

func (*Error) Error

func (e *Error) Error() string

Error implements error.Error()

func (*Error) SetActivityName

func (e *Error) SetActivityName(name string)

Set the activity name

type Factory added in v0.5.7

type Factory func(config *Config) (Activity, error)

func GetFactory added in v0.5.7

func GetFactory(ref string) Factory

type FlowDetails deprecated

type FlowDetails interface {

	// ID returns the ID of the Flow Instance
	ID() string

	// FlowName returns the name of the Flow
	Name() string

	// ReplyHandler returns the reply handler for the flow Instance
	ReplyHandler() ReplyHandler
}

Deprecated: Use ActivityHost() instead.

type Host

type Host interface {

	// ID returns the ID of the Activity Host
	ID() string

	// Name the name of the Activity Host
	Name() string

	// IOMetadata get the input/output metadata of the activity host
	IOMetadata() *data.IOMetadata

	// Reply is used to reply to the activity Host with the results of the execution
	Reply(replyData map[string]*data.Attribute, err error)

	// Return is used to indicate to the activity Host that it should complete and return the results of the execution
	Return(returnData map[string]*data.Attribute, err error)

	//todo rename, essentially the flow's attrs for now
	WorkingData() data.Scope

	// GetResolver gets the resolver associated with the activity host
	GetResolver() data.Resolver
}

type Metadata

type Metadata struct {
	ID             string
	Version        string
	Settings       map[string]*data.Attribute
	Input          map[string]*data.Attribute
	Output         map[string]*data.Attribute
	ProducesResult bool
	DynamicIO      bool
}

Metadata is the metadata for the Activity

func NewMetadata

func NewMetadata(jsonMetadata string) *Metadata

NewMetadata creates the metadata object from its json representation

func (*Metadata) UnmarshalJSON

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

UnmarshalJSON overrides the default UnmarshalJSON for TaskEnv

type ReplyHandler

type ReplyHandler interface {

	// Reply is used to reply with the results of the instance execution
	Reply(code int, data interface{}, err error)
}

ReplyHandler is used to reply back to whoever started the flow instance

type SharedTempDataSupport added in v0.5.6

type SharedTempDataSupport interface {

	// GetSharedTempData get shared temporary data for activity, lifespan
	// of the data dependent on the activity host implementation
	GetSharedTempData() map[string]interface{}
}

SharedTempDataSupport - temporary interface until we transition this to activity.Context Deprecated

func GetSharedTempDataSupport added in v0.5.6

func GetSharedTempDataSupport(ctx Context) (SharedTempDataSupport, bool)

GetSharedTempDataSupport for the activity

Jump to

Keyboard shortcuts

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