-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
responses.go
50 lines (43 loc) · 1.09 KB
/
responses.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
// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.
package querypb
import (
"strings"
"github.com/thanos-io/thanos/pkg/store/storepb/prompb"
)
func NewQueryResponse(series *prompb.TimeSeries) *QueryResponse {
return &QueryResponse{
Result: &QueryResponse_Timeseries{
Timeseries: series,
},
}
}
func NewQueryWarningsResponse(errs ...error) *QueryResponse {
warnings := make([]string, 0, len(errs))
for _, err := range errs {
warnings = append(warnings, err.Error())
}
return &QueryResponse{
Result: &QueryResponse_Warnings{
Warnings: strings.Join(warnings, ", "),
},
}
}
func NewQueryRangeResponse(series *prompb.TimeSeries) *QueryRangeResponse {
return &QueryRangeResponse{
Result: &QueryRangeResponse_Timeseries{
Timeseries: series,
},
}
}
func NewQueryRangeWarningsResponse(errs ...error) *QueryRangeResponse {
warnings := make([]string, 0, len(errs))
for _, err := range errs {
warnings = append(warnings, err.Error())
}
return &QueryRangeResponse{
Result: &QueryRangeResponse_Warnings{
Warnings: strings.Join(warnings, ", "),
},
}
}