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