activity

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2018 License: BSD-3-Clause Imports: 4 Imported by: 656

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(activity Activity)

Register registers the specified activity

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, evalError *Error)
}

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

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

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

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

	// 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{})

	// 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 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

Jump to

Keyboard shortcuts

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