mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
27 lines
529 B
Go
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
|
|
}
|