-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi.go
More file actions
38 lines (31 loc) · 743 Bytes
/
api.go
File metadata and controls
38 lines (31 loc) · 743 Bytes
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
package main
type message struct {
TimeNano int64 `json:"time"`
Tag string `json:"tag"`
Values []float64 `json:"values"`
}
// APIResponse is the struct for the client request
type APIResponse struct {
TagName string `json:"tagName"`
Start int64 `json:"start"`
End int64 `json:"end"`
Samples Samples `json:"samples"`
}
type sample struct {
Time int64 `json:"time"`
Values []float64 `json:"values"`
}
// Samples holds samples
type Samples []sample
// Len is
func (slice Samples) Len() int {
return len(slice)
}
// Less is
func (slice Samples) Less(i, j int) bool {
return slice[i].Time < slice[j].Time
}
// Swap is
func (slice Samples) Swap(i, j int) {
slice[i], slice[j] = slice[j], slice[i]
}