activity

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Activities

func Activities() map[string]Activity

func CleanupSingletons

func CleanupSingletons()

func GetLogger

func GetLogger(ref string) log.Logger

GetLogger gets activity logger by ref

func GetRef

func GetRef(activity Activity) string

func HasLegacyActivities

func HasLegacyActivities() bool

DEPRECATED

func IsLegacyActivity

func IsLegacyActivity(ref string) bool

DEPRECATED

func IsSingleton

func IsSingleton(activity Activity) bool

func LegacyRegister

func LegacyRegister(ref string, activity Activity) error

DEPRECATED

func Register

func Register(activity Activity, f ...Factory) error

Types

type Activity

type Activity interface {

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

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

Activity is an interface for defining a custom Activity Execution

func Get

func Get(ref string) Activity

Get gets specified activity by ref

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

type Config struct {
	Ref      string                 `json:"ref"`
	Settings map[string]interface{} `json:"settings,omitempty"`
	Input    map[string]interface{} `json:"input,omitempty"`
	Output   map[string]interface{} `json:"output,omitempty"`
	Schemas  *SchemaConfig          `json:"schemas,omitempty"`

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

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

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

	// GetInputObject gets all the activity input as the specified object.
	GetInputObject(input data.StructValue) error

	// SetOutputObject sets the activity output as the specified object.
	SetOutputObject(output data.StructValue) error

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

	// Logger the logger for the activity
	Logger() log.Logger

	// GetTracingContext returns tracing context associated with the activity
	GetTracingContext() trace.TracingContext
}

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

type Details

type Details struct {
	IsReturn bool
	IsReply  bool
}

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 NewRetriableError

func NewRetriableError(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) Retriable

func (e *Error) Retriable() bool

Retriable returns wether error is retriable

func (*Error) SetActivityName

func (e *Error) SetActivityName(name string)

Set the activity name

type Factory

type Factory func(ctx InitContext) (Activity, error)

func GetFactory

func GetFactory(ref string) Factory

GetFactory gets activity factory by ref

type HasDetails

type HasDetails interface {
	Details() *Details
}

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() *metadata.IOMetadata

	// Reply is used to reply to the activity Host with the results of the execution
	Reply(replyData map[string]interface{}, 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]interface{}, err error)

	// Scope returns the scope for the Host's data
	Scope() data.Scope
}

type InitContext

type InitContext interface {

	// Settings
	Settings() map[string]interface{}

	// MapperFactory gets the mapper factory associated with the activity host
	MapperFactory() mapper.Factory

	// Logger logger to using during initialization, activity implementations should not
	// keep a reference to this
	Logger() log.Logger

	// Name returns name of the activity / task
	Name() string
	// HostName returns name of the flow / task host
	HostName() string
}

type LegacyCtx

type LegacyCtx interface {

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

type Metadata

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

func ToMetadata

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

func (*Metadata) UnmarshalJSON

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

UnmarshalJSON overrides the default UnmarshalJSON for TaskEnv

type ReconfigurableActivity

type ReconfigurableActivity interface {
	Reconfigure(settings map[string]interface{}) error
}

type SchemaConfig

type SchemaConfig struct {
	Input  map[string]interface{} `json:"input,omitempty"`
	Output map[string]interface{} `json:"output,omitempty"`
}

Jump to

Keyboard shortcuts

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