-
Notifications
You must be signed in to change notification settings - Fork 125
/
protocol.go
182 lines (163 loc) · 4.49 KB
/
protocol.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package goflow
// PortInfo represents a port to a runtime client.
type PortInfo struct {
ID string `json:"id"`
Type string `json:"type"`
Description string `json:"description"`
Addressable bool `json:"addressable"` // ignored
Required bool `json:"required"`
Values []interface{} `json:"values"` // ignored
Default interface{} `json:"default"` // ignored
}
// ComponentInfo represents a component to a protocol client.
type ComponentInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Icon string `json:"icon"`
Subgraph bool `json:"subgraph"`
InPorts []PortInfo `json:"inPorts"`
OutPorts []PortInfo `json:"outPorts"`
}
// Message represents a single FBP protocol message.
type Message struct {
// Protocol is NoFlo protocol identifier:
// "runtime", "component", "graph" or "network"
Protocol string `json:"protocol"`
// Command is a command to be executed within the protocol
Command string `json:"command"`
// Payload is JSON-encoded body of the message
Payload interface{} `json:"payload"`
}
// runtimeInfo message contains response to runtime.getruntime request.
type runtimeInfo struct {
Type string `json:"type"`
Version string `json:"version"`
Capabilities []string `json:"capabilities"`
ID string `json:"id"`
}
type runtimeMessage struct {
Protocol string `json:"protocol"`
Command string `json:"command"`
Payload runtimeInfo `json:"payload"`
}
// clearGraph message is sent by client to create a new empty graph.
type clearGraph struct {
ID string
Name string `json:",omitempty"` // ignored
Library string `json:",omitempty"` // ignored
Main bool `json:",omitempty"`
Icon string `json:",omitempty"`
Description string `json:",omitempty"`
}
// addNode message is sent by client to add a node to a graph.
type addNode struct {
ID string
Component string
Graph string
Metadata map[string]interface{} `json:",omitempty"` // ignored
}
// removeNode is a client message to remove a node from a graph.
type removeNode struct {
ID string
Graph string
}
// renameNode is a client message to rename a node in a graph.
type renameNode struct {
From string
To string
Graph string
}
// changeNode is a client message to change the metadata associated with a node in the graph.
type changeNode struct { // ignored
ID string
Graph string
Metadata map[string]interface{}
}
// addEdge is a client message to create a connection in a graph.
type addEdge struct {
Src struct {
Node string
Port string
Index int `json:",omitempty"` // ignored
}
Tgt struct {
Node string
Port string
Index int `json:",omitempty"` // ignored
}
Graph string
Metadata map[string]interface{} `json:",omitempty"` // ignored
}
// removeEdge is a client message to delete a connection from a graph.
type removeEdge struct {
Src struct {
Node string
Port string
}
Tgt struct {
Node string
Port string
}
Graph string
}
// changeEdge is a client message to change connection metadata.
type changeEdge struct { // ignored
Src struct {
Node string
Port string
Index int `json:",omitempty"`
}
Tgt struct {
Node string
Port string
Index int `json:",omitempty"`
}
Graph string
Metadata map[string]interface{}
}
// addInitial is a client message to add an IIP to a graph.
type addInitial struct {
Src struct {
Data interface{}
}
Tgt struct {
Node string
Port string
Index int `json:",omitempty"` // ignored
}
Graph string
Metadata map[string]interface{} `json:",omitempty"` // ignored
}
// removeInitial is a client message to remove an IIP from a graph.
type removeInitial struct {
Tgt struct {
Node string
Port string
Index int `json:",omitempty"` // ignored
}
Graph string
}
// addPort is a client message to add an exported inport/outport to the graph.
type addPort struct {
Public string
Node string
Port string
Graph string
Metadata map[string]interface{} `json:",omitempty"` // ignored
}
// removePort is a client message to remove an exported inport/outport from the graph.
type removePort struct {
Public string
Graph string
}
// renamePort is a client message to rename a port of a graph.
type renamePort struct {
From string
To string
Graph string
}
type componentMessage struct {
Protocol string `json:"protocol"`
Command string `json:"command"`
Payload ComponentInfo `json:"payload"`
}