-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanemos.go
103 lines (87 loc) · 1.77 KB
/
anemos.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
package anemos
import (
//"fmt"
//"sync"
api "github.com/anemos-io/engine/grpc/anemos/v1alpha1"
//"log"
"strings"
)
type NodeInstanceStatus int
const (
Unknown NodeInstanceStatus = iota
Retry
Initialized
Queue
Start
Success
Skip
Fail
)
type Node interface {
Provider() string
Operation() string
Name() string
Attributes() map[string]string
//Name() (string)
AddUpstream(name string, node Node)
AddDownstream(name string, node Node)
Upstream() map[string]Node
Downstream() map[string]Node
Status() NodeInstanceStatus
EndStateReached() bool
AssignSession(session Session)
OnEvent(event *api.Event)
OnStart(event *api.Event)
OnProgress(event *api.Event)
OnFinish(event *api.Event)
OnCancel(event *api.Event)
OnSkip(event *api.Event)
}
type Group interface {
Node
AddNode(node Node)
Resolve()
}
type Session interface {
SetRouter(Router)
Router() Router
NewTaskInstance(node Node) *api.TaskInstance
}
type Executor interface {
Execute(*api.TaskInstance)
}
type Observer interface {
}
type Trigger interface {
Trigger(event *api.Event)
}
type Router interface {
StartTask(node Node, instance *api.TaskInstance)
StartVirtual(node Node, instance *api.TaskInstance)
Fail(node Node, instance *api.TaskInstance)
SignalDownstream(node Node)
RegisterSession(session Session)
}
type Uri struct {
Kind string
Provider string
Operation string
Name string
Id string
Status string
}
func ParseUri(us string) (*Uri, error) {
parts := strings.Split(us, ":")
return &Uri{
Kind: parts[0],
Provider: parts[1],
Operation: parts[2],
Name: parts[3],
Id: parts[4],
Status: parts[5],
}, nil
}
const (
MetaTaskRetry = "anemos/meta:anemos:task:retry"
MetaEventTimestamp = "anemos/meta:anemos:event:timestamp"
)