forked from sensorbee/sensorbee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stream.go
31 lines (27 loc) · 786 Bytes
/
stream.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
package response
import (
"gopkg.in/sensorbee/sensorbee.v0/core"
"gopkg.in/sensorbee/sensorbee.v0/data"
)
// Stream is a part of the response which is returned by streams' action.
type Stream struct {
NodeType string `json:"node_type"`
Name string `json:"name"`
State string `json:"state"`
Status data.Map `json:"status,omitempty"`
Meta interface{} `json:"meta,omitempty"`
}
// NewStream returns the result of the box node. It generates status and
// meta information if detailed argument is true.
func NewStream(bn core.BoxNode, detailed bool) *Stream {
s := &Stream{
NodeType: core.NTBox.String(),
Name: bn.Name(),
State: bn.State().Get().String(),
}
if detailed {
s.Status = bn.Status()
s.Meta = bn.Meta()
}
return s
}