Files
grafana/pkg/tsdb/request.go
2017-09-21 15:09:14 +02:00

27 lines
529 B
Go

package tsdb
import (
"context"
)
type HandleRequestFunc func(ctx context.Context, req *TsdbQuery) (*Response, error)
func HandleRequest(ctx context.Context, req *TsdbQuery) (*Response, error) {
//TODO niceify
ds := req.Queries[0].DataSource
endpoint, err := getTsdbQueryEndpointFor(ds)
if err != nil {
return nil, err
}
res := endpoint.Query(ctx, ds, req)
if res.Error != nil {
return nil, res.Error
}
return &Response{
Results: res.QueryResults,
BatchTimings: []*BatchTiming{res.Timings},
}, nil
}