github.com/thanos-io/thanos@v0.32.5/pkg/api/query/querypb/responses.go (about) 1 // Copyright (c) The Thanos Authors. 2 // Licensed under the Apache License 2.0. 3 4 package querypb 5 6 import ( 7 "strings" 8 9 "github.com/thanos-io/thanos/pkg/store/storepb/prompb" 10 ) 11 12 func NewQueryResponse(series *prompb.TimeSeries) *QueryResponse { 13 return &QueryResponse{ 14 Result: &QueryResponse_Timeseries{ 15 Timeseries: series, 16 }, 17 } 18 } 19 20 func NewQueryWarningsResponse(errs ...error) *QueryResponse { 21 warnings := make([]string, 0, len(errs)) 22 for _, err := range errs { 23 warnings = append(warnings, err.Error()) 24 } 25 return &QueryResponse{ 26 Result: &QueryResponse_Warnings{ 27 Warnings: strings.Join(warnings, ", "), 28 }, 29 } 30 } 31 32 func NewQueryRangeResponse(series *prompb.TimeSeries) *QueryRangeResponse { 33 return &QueryRangeResponse{ 34 Result: &QueryRangeResponse_Timeseries{ 35 Timeseries: series, 36 }, 37 } 38 } 39 40 func NewQueryRangeWarningsResponse(errs ...error) *QueryRangeResponse { 41 warnings := make([]string, 0, len(errs)) 42 for _, err := range errs { 43 warnings = append(warnings, err.Error()) 44 } 45 return &QueryRangeResponse{ 46 Result: &QueryRangeResponse_Warnings{ 47 Warnings: strings.Join(warnings, ", "), 48 }, 49 } 50 }