-
Notifications
You must be signed in to change notification settings - Fork 78
/
exec.go
57 lines (47 loc) · 1.35 KB
/
exec.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
package instance
import (
"github.com/TIBCOSoftware/flogo-contrib/action/flow/support"
"github.com/TIBCOSoftware/flogo-lib/logger"
)
const (
OpStart = iota // 0
OpResume // 1
OpRestart // 2
)
// RunOptions the options when running a FlowAction
type RunOptions struct {
Op int
ReturnID bool
FlowURI string
InitialState *IndependentInstance
ExecOptions *ExecOptions
}
// ExecOptions are optional Patch & Interceptor to be used during instance execution
type ExecOptions struct {
Patch *support.Patch
Interceptor *support.Interceptor
}
// IDGenerator generates IDs for flow instances
type IDGenerator interface {
//NewFlowInstanceID generate a new instance ID
NewFlowInstanceID() string
}
// ApplyExecOptions applies any execution options to the flow instance
func ApplyExecOptions(instance *IndependentInstance, execOptions *ExecOptions) {
if execOptions != nil {
if execOptions.Patch != nil {
logger.Infof("Instance [%s] has patch", instance.ID())
instance.patch = execOptions.Patch
instance.patch.Init()
}
if execOptions.Interceptor != nil {
logger.Infof("Instance [%s] has interceptor", instance.ID())
instance.interceptor = execOptions.Interceptor
instance.interceptor.Init()
}
}
}
// IDResponse is a response object consists of an ID
type IDResponse struct {
ID string `json:"id"`
}