mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 17:15:08 -05:00
Expressions: Move GEL into core as expressions (#29072)
* comes from grafana/gel-app * remove transform plugin code * move __expr__ and -100 constants to expr pkg * set OrgID on request plugin context * use gtime for resample duration * in resample, rename "rule" to "window", use gtime for duration, parse duration before exec * remove gel entry from plugins-bundled/external.json which creates an empty array for plugins
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package expr
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
)
|
||||
|
||||
// DatasourceName is the string constant used as the datasource name in requests
|
||||
// to identify it as an expression command.
|
||||
const DatasourceName = "__expr__"
|
||||
|
||||
// DatasourceID is the fake datasource id used in requests to identify it as an
|
||||
// expression command.
|
||||
const DatasourceID = -100
|
||||
|
||||
// Service is service representation for expression handling.
|
||||
type Service struct {
|
||||
}
|
||||
|
||||
// BuildPipeline builds a pipeline from a request.
|
||||
func (s *Service) BuildPipeline(queries []backend.DataQuery) (DataPipeline, error) {
|
||||
return buildPipeline(queries)
|
||||
}
|
||||
|
||||
// ExecutePipeline executes an expression pipeline and returns all the results.
|
||||
func (s *Service) ExecutePipeline(ctx context.Context, pipeline DataPipeline) (*backend.QueryDataResponse, error) {
|
||||
res := backend.NewQueryDataResponse()
|
||||
vars, err := pipeline.execute(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for refID, val := range vars {
|
||||
res.Responses[refID] = backend.DataResponse{
|
||||
Frames: val.Values.AsDataFrames(refID),
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
Reference in New Issue
Block a user