forked from sensorbee/sensorbee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sink.go
31 lines (27 loc) · 775 Bytes
/
sink.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"
)
// Sink is a part of the response which is returned by sinks' action.
type Sink 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"`
}
// NewSink returns the result of the sink node. It generates status and
// meta information if detailed argument is true.
func NewSink(sn core.SinkNode, detailed bool) *Sink {
s := &Sink{
NodeType: core.NTSink.String(),
Name: sn.Name(),
State: sn.State().Get().String(),
}
if detailed {
s.Status = sn.Status()
s.Meta = sn.Meta()
}
return s
}