forked from project-flogo/contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivity.go
38 lines (29 loc) · 818 Bytes
/
activity.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
package error
import (
"github.com/project-flogo/core/activity"
)
func init() {
_ = activity.Register(&Activity{})
}
var activityMd = activity.ToMetadata(&Input{})
// Activity is an Activity that used to cause an explicit error in the flow
// inputs : {message,data}
// outputs: node
type Activity struct {
}
// Metadata returns the activity's metadata
func (a *Activity) Metadata() *activity.Metadata {
return activityMd
}
// Eval returns an error
func (a *Activity) Eval(ctx activity.Context) (done bool, err error) {
input := &Input{}
err = ctx.GetInputObject(input)
if err != nil {
return false, err
}
if logger := ctx.Logger(); logger.DebugEnabled() {
logger.Debugf("Message :'%s', Data: '%+v'", input.Message, input.Data)
}
return false, activity.NewError(input.Message, "", input.Data)
}