-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgraph.go
32 lines (29 loc) · 794 Bytes
/
graph.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
package main
import (
"github.com/trustmaster/goflow"
)
// A graph for our app
type App struct {
flow.Graph
}
// A constructor that creates network structure
func NewApp() *App {
// Create a new graph
net := new(App)
net.InitGraphState()
// Add graph nodes
net.Add(new(Router), "router")
net.Add(new(Controller), "controller")
net.Add(new(SendController), "sender")
net.Add(NewStorage(), "storage")
net.Add(new(Responder), "responder")
// Connect the processes
net.Connect("router", "Show", "controller", "In")
net.Connect("router", "Send", "sender", "In")
net.Connect("controller", "Out", "storage", "Get")
net.Connect("sender", "Out", "storage", "Post")
net.Connect("storage", "Out", "responder", "In")
// Network ports
net.MapInPort("In", "router", "In")
return net
}