/
context.go
105 lines (73 loc) · 2.89 KB
/
context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package activity
import (
"github.com/TIBCOSoftware/flogo-lib/core/data"
)
// Context describes the execution context for an Activity.
// It provides access to attributes, task and Flow information.
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{})
//// GetSharedTempData get shared temporary data for activity, lifespan
//// of the data dependent on the activity host implementation
//GetSharedTempData() map[string]interface{}
/////////////////
// Deprecated
// 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
/////////////////
}
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
//Map with action specific details/properties, flowId, etc.
//GetDetails() map[string]string
}
// Deprecated: Use ActivityHost() instead.
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
}
//SharedTempDataSupport - temporary interface until we transition this to activity.Context
//Deprecated
type SharedTempDataSupport interface {
// GetSharedTempData get shared temporary data for activity, lifespan
// of the data dependent on the activity host implementation
GetSharedTempData() map[string]interface{}
}
// GetSharedTempDataSupport for the activity
func GetSharedTempDataSupport(ctx Context) (SharedTempDataSupport, bool) {
ts, ok := ctx.(SharedTempDataSupport)
return ts, ok
}