moves datasource plugin model to grafana/grafana_plugin_model

This commit is contained in:
bergquist
2018-01-17 11:37:37 +01:00
parent af9d1cc577
commit a183ea97bb
10 changed files with 418 additions and 320 deletions

View File

@@ -1,23 +0,0 @@
package tsdb
import (
"context"
proto "github.com/grafana/grafana/pkg/tsdb/models"
)
type GRPCClient struct {
proto.TsdbPluginClient
}
func (m *GRPCClient) Query(ctx context.Context, req *proto.TsdbQuery) (*proto.Response, error) {
return m.TsdbPluginClient.Query(ctx, req)
}
type GRPCServer struct {
TsdbPlugin
}
func (m *GRPCServer) Query(ctx context.Context, req *proto.TsdbQuery) (*proto.Response, error) {
return m.TsdbPlugin.Query(ctx, req)
}

View File

@@ -1,27 +0,0 @@
package tsdb
import (
"context"
proto "github.com/grafana/grafana/pkg/tsdb/models"
plugin "github.com/hashicorp/go-plugin"
"google.golang.org/grpc"
)
type TsdbPlugin interface {
Query(ctx context.Context, req *proto.TsdbQuery) (*proto.Response, error)
}
type TsdbPluginImpl struct {
plugin.NetRPCUnsupportedPlugin
Plugin TsdbPlugin
}
func (p *TsdbPluginImpl) GRPCServer(s *grpc.Server) error {
proto.RegisterTsdbPluginServer(s, &GRPCServer{p.Plugin})
return nil
}
func (p *TsdbPluginImpl) GRPCClient(c *grpc.ClientConn) (interface{}, error) {
return &GRPCClient{proto.NewTsdbPluginClient(c)}, nil
}

View File

@@ -1,4 +1,4 @@
package tsdb
package wrapper
import (
"context"
@@ -8,16 +8,15 @@ import (
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/tsdb"
proto "github.com/grafana/grafana/pkg/tsdb/models"
"github.com/grafana/grafana_plugin_model/go/datasource"
)
func NewDatasourcePluginWrapper(log log.Logger, plugin TsdbPlugin) *DatasourcePluginWrapper {
return &DatasourcePluginWrapper{TsdbPlugin: plugin, logger: log}
func NewDatasourcePluginWrapper(log log.Logger, plugin datasource.DatasourcePlugin) *DatasourcePluginWrapper {
return &DatasourcePluginWrapper{DatasourcePlugin: plugin, logger: log}
}
type DatasourcePluginWrapper struct {
TsdbPlugin
datasource.DatasourcePlugin
logger log.Logger
}
@@ -27,8 +26,8 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
return nil, err
}
pbQuery := &proto.TsdbQuery{
Datasource: &proto.DatasourceInfo{
pbQuery := &datasource.DatasourceRequest{
Datasource: &datasource.DatasourceInfo{
JsonData: string(jsonData),
Name: ds.Name,
Type: ds.Type,
@@ -36,19 +35,19 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
Id: ds.Id,
OrgId: ds.OrgId,
},
TimeRange: &proto.TimeRange{
TimeRange: &datasource.TimeRange{
FromRaw: query.TimeRange.From,
ToRaw: query.TimeRange.To,
ToEpochMs: query.TimeRange.GetToAsMsEpoch(),
FromEpochMs: query.TimeRange.GetFromAsMsEpoch(),
},
Queries: []*proto.Query{},
Queries: []*datasource.Query{},
}
for _, q := range query.Queries {
modelJson, _ := q.Model.MarshalJSON()
pbQuery.Queries = append(pbQuery.Queries, &proto.Query{
pbQuery.Queries = append(pbQuery.Queries, &datasource.Query{
ModelJson: string(modelJson),
IntervalMs: q.IntervalMs,
RefId: q.RefId,
@@ -56,7 +55,7 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
})
}
pbres, err := tw.TsdbPlugin.Query(ctx, pbQuery)
pbres, err := tw.DatasourcePlugin.Query(ctx, pbQuery)
if err != nil {
return nil, err
@@ -96,7 +95,7 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
return res, nil
}
func (tw *DatasourcePluginWrapper) mapTables(r *proto.QueryResult) ([]*tsdb.Table, error) {
func (tw *DatasourcePluginWrapper) mapTables(r *datasource.QueryResult) ([]*tsdb.Table, error) {
var tables []*tsdb.Table
for _, t := range r.GetTables() {
mappedTable, err := tw.mapTable(t)
@@ -108,7 +107,7 @@ func (tw *DatasourcePluginWrapper) mapTables(r *proto.QueryResult) ([]*tsdb.Tabl
return tables, nil
}
func (tw *DatasourcePluginWrapper) mapTable(t *proto.Table) (*tsdb.Table, error) {
func (tw *DatasourcePluginWrapper) mapTable(t *datasource.Table) (*tsdb.Table, error) {
table := &tsdb.Table{}
for _, c := range t.GetColumns() {
table.Columns = append(table.Columns, tsdb.TableColumn{
@@ -131,19 +130,19 @@ func (tw *DatasourcePluginWrapper) mapTable(t *proto.Table) (*tsdb.Table, error)
return table, nil
}
func (tw *DatasourcePluginWrapper) mapRowValue(rv *proto.RowValue) (interface{}, error) {
func (tw *DatasourcePluginWrapper) mapRowValue(rv *datasource.RowValue) (interface{}, error) {
switch rv.Kind {
case proto.RowValue_TYPE_NULL:
case datasource.RowValue_TYPE_NULL:
return nil, nil
case proto.RowValue_TYPE_INT64:
case datasource.RowValue_TYPE_INT64:
return rv.Int64Value, nil
case proto.RowValue_TYPE_BOOL:
case datasource.RowValue_TYPE_BOOL:
return rv.BoolValue, nil
case proto.RowValue_TYPE_STRING:
case datasource.RowValue_TYPE_STRING:
return rv.StringValue, nil
case proto.RowValue_TYPE_DOUBLE:
case datasource.RowValue_TYPE_DOUBLE:
return rv.DoubleValue, nil
case proto.RowValue_TYPE_BYTES:
case datasource.RowValue_TYPE_BYTES:
return rv.BytesValue, nil
default:
return nil, fmt.Errorf("Unsupported row value %v from plugin", rv.Kind)

View File

@@ -1,17 +1,18 @@
package tsdb
package wrapper
import (
"testing"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/tsdb"
"github.com/grafana/grafana/pkg/tsdb/models"
"testing"
"github.com/grafana/grafana_plugin_model/go/datasource"
)
func TestMapTables(t *testing.T) {
dpw := NewDatasourcePluginWrapper(log.New("test-logger"), nil)
var qr = &proto.QueryResult{}
qr.Tables = append(qr.Tables, &proto.Table{
Columns: []*proto.TableColumn{},
var qr = &datasource.QueryResult{}
qr.Tables = append(qr.Tables, &datasource.Table{
Columns: []*datasource.TableColumn{},
Rows: nil,
})
want := []*tsdb.Table{{}}
@@ -28,16 +29,16 @@ func TestMapTables(t *testing.T) {
func TestMapTable(t *testing.T) {
dpw := NewDatasourcePluginWrapper(log.New("test-logger"), nil)
source := &proto.Table{
Columns: []*proto.TableColumn{{Name: "column1"}, {Name: "column2"}},
Rows: []*proto.TableRow{{
Values: []*proto.RowValue{
source := &datasource.Table{
Columns: []*datasource.TableColumn{{Name: "column1"}, {Name: "column2"}},
Rows: []*datasource.TableRow{{
Values: []*datasource.RowValue{
{
Kind: proto.RowValue_TYPE_BOOL,
Kind: datasource.RowValue_TYPE_BOOL,
BoolValue: true,
},
{
Kind: proto.RowValue_TYPE_INT64,
Kind: datasource.RowValue_TYPE_INT64,
Int64Value: 42,
},
},
@@ -71,37 +72,37 @@ func TestMapTable(t *testing.T) {
func TestMappingRowValue(t *testing.T) {
dpw := NewDatasourcePluginWrapper(log.New("test-logger"), nil)
boolRowValue, _ := dpw.mapRowValue(&proto.RowValue{Kind: proto.RowValue_TYPE_BOOL, BoolValue: true})
boolRowValue, _ := dpw.mapRowValue(&datasource.RowValue{Kind: datasource.RowValue_TYPE_BOOL, BoolValue: true})
haveBool, ok := boolRowValue.(bool)
if !ok || haveBool != true {
t.Fatalf("Expected true, was %s", haveBool)
}
intRowValue, _ := dpw.mapRowValue(&proto.RowValue{Kind: proto.RowValue_TYPE_INT64, Int64Value: 42})
intRowValue, _ := dpw.mapRowValue(&datasource.RowValue{Kind: datasource.RowValue_TYPE_INT64, Int64Value: 42})
haveInt, ok := intRowValue.(int64)
if !ok || haveInt != 42 {
t.Fatalf("Expected %d, was %d", 42, haveInt)
}
stringRowValue, _ := dpw.mapRowValue(&proto.RowValue{Kind: proto.RowValue_TYPE_STRING, StringValue: "grafana"})
stringRowValue, _ := dpw.mapRowValue(&datasource.RowValue{Kind: datasource.RowValue_TYPE_STRING, StringValue: "grafana"})
haveString, ok := stringRowValue.(string)
if !ok || haveString != "grafana" {
t.Fatalf("Expected %s, was %s", "grafana", haveString)
}
doubleRowValue, _ := dpw.mapRowValue(&proto.RowValue{Kind: proto.RowValue_TYPE_DOUBLE, DoubleValue: 1.5})
doubleRowValue, _ := dpw.mapRowValue(&datasource.RowValue{Kind: datasource.RowValue_TYPE_DOUBLE, DoubleValue: 1.5})
haveDouble, ok := doubleRowValue.(float64)
if !ok || haveDouble != 1.5 {
t.Fatalf("Expected %v, was %v", 1.5, haveDouble)
}
bytesRowValue, _ := dpw.mapRowValue(&proto.RowValue{Kind: proto.RowValue_TYPE_BYTES, BytesValue: []byte{66}})
bytesRowValue, _ := dpw.mapRowValue(&datasource.RowValue{Kind: datasource.RowValue_TYPE_BYTES, BytesValue: []byte{66}})
haveBytes, ok := bytesRowValue.([]byte)
if !ok || len(haveBytes) != 1 || haveBytes[0] != 66 {
t.Fatalf("Expected %v, was %v", []byte{66}, haveBytes)
}
haveNil, _ := dpw.mapRowValue(&proto.RowValue{Kind: proto.RowValue_TYPE_NULL})
haveNil, _ := dpw.mapRowValue(&datasource.RowValue{Kind: datasource.RowValue_TYPE_NULL})
if haveNil != nil {
t.Fatalf("Expected %v, was %v", nil, haveNil)
}

View File

@@ -14,8 +14,9 @@ import (
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/models"
shared "github.com/grafana/grafana/pkg/plugins/datasource/tsdb"
"github.com/grafana/grafana/pkg/plugins/datasource/wrapper"
"github.com/grafana/grafana/pkg/tsdb"
"github.com/grafana/grafana_plugin_model/go/datasource"
plugin "github.com/hashicorp/go-plugin"
)
@@ -92,7 +93,7 @@ func (p *DataSourcePlugin) spawnSubProcess() error {
p.client = plugin.NewClient(&plugin.ClientConfig{
HandshakeConfig: handshakeConfig,
Plugins: map[string]plugin.Plugin{p.Id: &shared.TsdbPluginImpl{}},
Plugins: map[string]plugin.Plugin{p.Id: &datasource.DatasourcePluginImpl{}},
Cmd: exec.Command(fullpath),
AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},
Logger: LogWrapper{Logger: p.log},
@@ -108,10 +109,10 @@ func (p *DataSourcePlugin) spawnSubProcess() error {
return err
}
plugin := raw.(shared.TsdbPlugin)
plugin := raw.(datasource.DatasourcePlugin)
tsdb.RegisterTsdbQueryEndpoint(p.Id, func(dsInfo *models.DataSource) (tsdb.TsdbQueryEndpoint, error) {
return shared.NewDatasourcePluginWrapper(p.log, plugin), nil
return wrapper.NewDatasourcePluginWrapper(p.log, plugin), nil
})
return nil

View File

@@ -1,636 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: tsdb_plugin.proto
/*
Package proto is a generated protocol buffer package.
It is generated from these files:
tsdb_plugin.proto
It has these top-level messages:
TsdbQuery
Query
TimeRange
Response
QueryResult
Table
TableColumn
TableRow
RowValue
DatasourceInfo
TimeSeries
Point
*/
package proto
import proto1 "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto1.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package
type RowValue_Kind int32
const (
// Field type null.
RowValue_TYPE_NULL RowValue_Kind = 0
// Field type double.
RowValue_TYPE_DOUBLE RowValue_Kind = 1
// Field type int64.
RowValue_TYPE_INT64 RowValue_Kind = 2
// Field type bool.
RowValue_TYPE_BOOL RowValue_Kind = 3
// Field type string.
RowValue_TYPE_STRING RowValue_Kind = 4
// Field type bytes.
RowValue_TYPE_BYTES RowValue_Kind = 5
)
var RowValue_Kind_name = map[int32]string{
0: "TYPE_NULL",
1: "TYPE_DOUBLE",
2: "TYPE_INT64",
3: "TYPE_BOOL",
4: "TYPE_STRING",
5: "TYPE_BYTES",
}
var RowValue_Kind_value = map[string]int32{
"TYPE_NULL": 0,
"TYPE_DOUBLE": 1,
"TYPE_INT64": 2,
"TYPE_BOOL": 3,
"TYPE_STRING": 4,
"TYPE_BYTES": 5,
}
func (x RowValue_Kind) String() string {
return proto1.EnumName(RowValue_Kind_name, int32(x))
}
func (RowValue_Kind) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{8, 0} }
type TsdbQuery struct {
TimeRange *TimeRange `protobuf:"bytes,1,opt,name=timeRange" json:"timeRange,omitempty"`
Datasource *DatasourceInfo `protobuf:"bytes,2,opt,name=datasource" json:"datasource,omitempty"`
Queries []*Query `protobuf:"bytes,3,rep,name=queries" json:"queries,omitempty"`
}
func (m *TsdbQuery) Reset() { *m = TsdbQuery{} }
func (m *TsdbQuery) String() string { return proto1.CompactTextString(m) }
func (*TsdbQuery) ProtoMessage() {}
func (*TsdbQuery) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *TsdbQuery) GetTimeRange() *TimeRange {
if m != nil {
return m.TimeRange
}
return nil
}
func (m *TsdbQuery) GetDatasource() *DatasourceInfo {
if m != nil {
return m.Datasource
}
return nil
}
func (m *TsdbQuery) GetQueries() []*Query {
if m != nil {
return m.Queries
}
return nil
}
type Query struct {
RefId string `protobuf:"bytes,1,opt,name=refId" json:"refId,omitempty"`
MaxDataPoints int64 `protobuf:"varint,2,opt,name=maxDataPoints" json:"maxDataPoints,omitempty"`
IntervalMs int64 `protobuf:"varint,3,opt,name=intervalMs" json:"intervalMs,omitempty"`
ModelJson string `protobuf:"bytes,4,opt,name=modelJson" json:"modelJson,omitempty"`
}
func (m *Query) Reset() { *m = Query{} }
func (m *Query) String() string { return proto1.CompactTextString(m) }
func (*Query) ProtoMessage() {}
func (*Query) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *Query) GetRefId() string {
if m != nil {
return m.RefId
}
return ""
}
func (m *Query) GetMaxDataPoints() int64 {
if m != nil {
return m.MaxDataPoints
}
return 0
}
func (m *Query) GetIntervalMs() int64 {
if m != nil {
return m.IntervalMs
}
return 0
}
func (m *Query) GetModelJson() string {
if m != nil {
return m.ModelJson
}
return ""
}
type TimeRange struct {
FromRaw string `protobuf:"bytes,1,opt,name=fromRaw" json:"fromRaw,omitempty"`
ToRaw string `protobuf:"bytes,2,opt,name=toRaw" json:"toRaw,omitempty"`
FromEpochMs int64 `protobuf:"varint,3,opt,name=fromEpochMs" json:"fromEpochMs,omitempty"`
ToEpochMs int64 `protobuf:"varint,4,opt,name=toEpochMs" json:"toEpochMs,omitempty"`
}
func (m *TimeRange) Reset() { *m = TimeRange{} }
func (m *TimeRange) String() string { return proto1.CompactTextString(m) }
func (*TimeRange) ProtoMessage() {}
func (*TimeRange) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *TimeRange) GetFromRaw() string {
if m != nil {
return m.FromRaw
}
return ""
}
func (m *TimeRange) GetToRaw() string {
if m != nil {
return m.ToRaw
}
return ""
}
func (m *TimeRange) GetFromEpochMs() int64 {
if m != nil {
return m.FromEpochMs
}
return 0
}
func (m *TimeRange) GetToEpochMs() int64 {
if m != nil {
return m.ToEpochMs
}
return 0
}
type Response struct {
Results []*QueryResult `protobuf:"bytes,1,rep,name=results" json:"results,omitempty"`
}
func (m *Response) Reset() { *m = Response{} }
func (m *Response) String() string { return proto1.CompactTextString(m) }
func (*Response) ProtoMessage() {}
func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *Response) GetResults() []*QueryResult {
if m != nil {
return m.Results
}
return nil
}
type QueryResult struct {
Error string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"`
RefId string `protobuf:"bytes,2,opt,name=refId" json:"refId,omitempty"`
MetaJson string `protobuf:"bytes,3,opt,name=metaJson" json:"metaJson,omitempty"`
Series []*TimeSeries `protobuf:"bytes,4,rep,name=series" json:"series,omitempty"`
Tables []*Table `protobuf:"bytes,5,rep,name=tables" json:"tables,omitempty"`
}
func (m *QueryResult) Reset() { *m = QueryResult{} }
func (m *QueryResult) String() string { return proto1.CompactTextString(m) }
func (*QueryResult) ProtoMessage() {}
func (*QueryResult) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *QueryResult) GetError() string {
if m != nil {
return m.Error
}
return ""
}
func (m *QueryResult) GetRefId() string {
if m != nil {
return m.RefId
}
return ""
}
func (m *QueryResult) GetMetaJson() string {
if m != nil {
return m.MetaJson
}
return ""
}
func (m *QueryResult) GetSeries() []*TimeSeries {
if m != nil {
return m.Series
}
return nil
}
func (m *QueryResult) GetTables() []*Table {
if m != nil {
return m.Tables
}
return nil
}
type Table struct {
Columns []*TableColumn `protobuf:"bytes,1,rep,name=columns" json:"columns,omitempty"`
Rows []*TableRow `protobuf:"bytes,2,rep,name=rows" json:"rows,omitempty"`
}
func (m *Table) Reset() { *m = Table{} }
func (m *Table) String() string { return proto1.CompactTextString(m) }
func (*Table) ProtoMessage() {}
func (*Table) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
func (m *Table) GetColumns() []*TableColumn {
if m != nil {
return m.Columns
}
return nil
}
func (m *Table) GetRows() []*TableRow {
if m != nil {
return m.Rows
}
return nil
}
type TableColumn struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (m *TableColumn) Reset() { *m = TableColumn{} }
func (m *TableColumn) String() string { return proto1.CompactTextString(m) }
func (*TableColumn) ProtoMessage() {}
func (*TableColumn) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
func (m *TableColumn) GetName() string {
if m != nil {
return m.Name
}
return ""
}
type TableRow struct {
Values []*RowValue `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"`
}
func (m *TableRow) Reset() { *m = TableRow{} }
func (m *TableRow) String() string { return proto1.CompactTextString(m) }
func (*TableRow) ProtoMessage() {}
func (*TableRow) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func (m *TableRow) GetValues() []*RowValue {
if m != nil {
return m.Values
}
return nil
}
type RowValue struct {
Kind RowValue_Kind `protobuf:"varint,1,opt,name=kind,enum=plugins.RowValue_Kind" json:"kind,omitempty"`
DoubleValue float64 `protobuf:"fixed64,2,opt,name=doubleValue" json:"doubleValue,omitempty"`
Int64Value int64 `protobuf:"varint,3,opt,name=int64Value" json:"int64Value,omitempty"`
BoolValue bool `protobuf:"varint,4,opt,name=boolValue" json:"boolValue,omitempty"`
StringValue string `protobuf:"bytes,5,opt,name=stringValue" json:"stringValue,omitempty"`
BytesValue []byte `protobuf:"bytes,6,opt,name=bytesValue,proto3" json:"bytesValue,omitempty"`
}
func (m *RowValue) Reset() { *m = RowValue{} }
func (m *RowValue) String() string { return proto1.CompactTextString(m) }
func (*RowValue) ProtoMessage() {}
func (*RowValue) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
func (m *RowValue) GetKind() RowValue_Kind {
if m != nil {
return m.Kind
}
return RowValue_TYPE_NULL
}
func (m *RowValue) GetDoubleValue() float64 {
if m != nil {
return m.DoubleValue
}
return 0
}
func (m *RowValue) GetInt64Value() int64 {
if m != nil {
return m.Int64Value
}
return 0
}
func (m *RowValue) GetBoolValue() bool {
if m != nil {
return m.BoolValue
}
return false
}
func (m *RowValue) GetStringValue() string {
if m != nil {
return m.StringValue
}
return ""
}
func (m *RowValue) GetBytesValue() []byte {
if m != nil {
return m.BytesValue
}
return nil
}
type DatasourceInfo struct {
Id int64 `protobuf:"varint,1,opt,name=id" json:"id,omitempty"`
OrgId int64 `protobuf:"varint,2,opt,name=orgId" json:"orgId,omitempty"`
Name string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
Type string `protobuf:"bytes,4,opt,name=type" json:"type,omitempty"`
Url string `protobuf:"bytes,5,opt,name=url" json:"url,omitempty"`
JsonData string `protobuf:"bytes,6,opt,name=jsonData" json:"jsonData,omitempty"`
SecureJsonData string `protobuf:"bytes,7,opt,name=secureJsonData" json:"secureJsonData,omitempty"`
}
func (m *DatasourceInfo) Reset() { *m = DatasourceInfo{} }
func (m *DatasourceInfo) String() string { return proto1.CompactTextString(m) }
func (*DatasourceInfo) ProtoMessage() {}
func (*DatasourceInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
func (m *DatasourceInfo) GetId() int64 {
if m != nil {
return m.Id
}
return 0
}
func (m *DatasourceInfo) GetOrgId() int64 {
if m != nil {
return m.OrgId
}
return 0
}
func (m *DatasourceInfo) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *DatasourceInfo) GetType() string {
if m != nil {
return m.Type
}
return ""
}
func (m *DatasourceInfo) GetUrl() string {
if m != nil {
return m.Url
}
return ""
}
func (m *DatasourceInfo) GetJsonData() string {
if m != nil {
return m.JsonData
}
return ""
}
func (m *DatasourceInfo) GetSecureJsonData() string {
if m != nil {
return m.SecureJsonData
}
return ""
}
type TimeSeries struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Tags map[string]string `protobuf:"bytes,2,rep,name=tags" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
Points []*Point `protobuf:"bytes,3,rep,name=points" json:"points,omitempty"`
}
func (m *TimeSeries) Reset() { *m = TimeSeries{} }
func (m *TimeSeries) String() string { return proto1.CompactTextString(m) }
func (*TimeSeries) ProtoMessage() {}
func (*TimeSeries) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
func (m *TimeSeries) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *TimeSeries) GetTags() map[string]string {
if m != nil {
return m.Tags
}
return nil
}
func (m *TimeSeries) GetPoints() []*Point {
if m != nil {
return m.Points
}
return nil
}
type Point struct {
Timestamp int64 `protobuf:"varint,1,opt,name=timestamp" json:"timestamp,omitempty"`
Value float64 `protobuf:"fixed64,2,opt,name=value" json:"value,omitempty"`
}
func (m *Point) Reset() { *m = Point{} }
func (m *Point) String() string { return proto1.CompactTextString(m) }
func (*Point) ProtoMessage() {}
func (*Point) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
func (m *Point) GetTimestamp() int64 {
if m != nil {
return m.Timestamp
}
return 0
}
func (m *Point) GetValue() float64 {
if m != nil {
return m.Value
}
return 0
}
func init() {
proto1.RegisterType((*TsdbQuery)(nil), "plugins.TsdbQuery")
proto1.RegisterType((*Query)(nil), "plugins.Query")
proto1.RegisterType((*TimeRange)(nil), "plugins.TimeRange")
proto1.RegisterType((*Response)(nil), "plugins.Response")
proto1.RegisterType((*QueryResult)(nil), "plugins.QueryResult")
proto1.RegisterType((*Table)(nil), "plugins.Table")
proto1.RegisterType((*TableColumn)(nil), "plugins.TableColumn")
proto1.RegisterType((*TableRow)(nil), "plugins.TableRow")
proto1.RegisterType((*RowValue)(nil), "plugins.RowValue")
proto1.RegisterType((*DatasourceInfo)(nil), "plugins.DatasourceInfo")
proto1.RegisterType((*TimeSeries)(nil), "plugins.TimeSeries")
proto1.RegisterType((*Point)(nil), "plugins.Point")
proto1.RegisterEnum("plugins.RowValue_Kind", RowValue_Kind_name, RowValue_Kind_value)
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// Client API for TsdbPlugin service
type TsdbPluginClient interface {
Query(ctx context.Context, in *TsdbQuery, opts ...grpc.CallOption) (*Response, error)
}
type tsdbPluginClient struct {
cc *grpc.ClientConn
}
func NewTsdbPluginClient(cc *grpc.ClientConn) TsdbPluginClient {
return &tsdbPluginClient{cc}
}
func (c *tsdbPluginClient) Query(ctx context.Context, in *TsdbQuery, opts ...grpc.CallOption) (*Response, error) {
out := new(Response)
err := grpc.Invoke(ctx, "/plugins.TsdbPlugin/Query", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for TsdbPlugin service
type TsdbPluginServer interface {
Query(context.Context, *TsdbQuery) (*Response, error)
}
func RegisterTsdbPluginServer(s *grpc.Server, srv TsdbPluginServer) {
s.RegisterService(&_TsdbPlugin_serviceDesc, srv)
}
func _TsdbPlugin_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TsdbQuery)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TsdbPluginServer).Query(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/plugins.TsdbPlugin/Query",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TsdbPluginServer).Query(ctx, req.(*TsdbQuery))
}
return interceptor(ctx, in, info, handler)
}
var _TsdbPlugin_serviceDesc = grpc.ServiceDesc{
ServiceName: "plugins.TsdbPlugin",
HandlerType: (*TsdbPluginServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Query",
Handler: _TsdbPlugin_Query_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "tsdb_plugin.proto",
}
func init() { proto1.RegisterFile("tsdb_plugin.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 811 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x55, 0x5d, 0x8f, 0x1b, 0x35,
0x14, 0x65, 0xbe, 0x92, 0xcc, 0x0d, 0x0d, 0xa9, 0xa9, 0x20, 0x5a, 0x01, 0x5a, 0x46, 0x50, 0x05,
0x90, 0x22, 0x08, 0xa5, 0x45, 0x85, 0xa7, 0xd0, 0x08, 0xa5, 0x84, 0xdd, 0xc5, 0x3b, 0x45, 0x2a,
0x0f, 0x54, 0x93, 0x8c, 0x13, 0x86, 0xce, 0x8c, 0x83, 0xed, 0xd9, 0x10, 0xf1, 0xc4, 0x3f, 0xe1,
0x99, 0x67, 0x7e, 0x00, 0x3f, 0xad, 0xf2, 0x1d, 0xcf, 0x47, 0xd2, 0x7d, 0x9a, 0xb9, 0xe7, 0x1c,
0x5f, 0x5f, 0x5f, 0x1f, 0xdb, 0x70, 0x57, 0xc9, 0x78, 0xf5, 0x62, 0x97, 0x16, 0xdb, 0x24, 0x9f,
0xec, 0x04, 0x57, 0x9c, 0x74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df, 0x25, 0xcf, 0xf5,
0xac, 0xb8, 0x70, 0x9f, 0xd6, 0x31, 0xb9, 0x0f, 0x03, 0xc9, 0xd6, 0x85, 0x60, 0x4f, 0x2b, 0x45,
0x17, 0x15, 0x27, 0xa8, 0x2e, 0x1b, 0x1a, 0xcb, 0xdf, 0xe6, 0x29, 0xf2, 0x05, 0xb8, 0x2a, 0xda,
0x56, 0xee, 0x7c, 0xff, 0x96, 0x93, 0x32, 0x09, 0xa3, 0xad, 0x9c, 0xe7, 0x4a, 0x1c, 0x28, 0x4a,
0xf5, 0x89, 0xd9, 0x95, 0x97, 0xd9, 0xe9, 0xe5, 0x88, 0xd7, 0x19, 0x35, 0xec, 0xd9, 0x23, 0xf0,
0xeb, 0xa1, 0x7a, 0x81, 0x2f, 0xd9, 0xc1, 0x4c, 0xad, 0x7f, 0x75, 0xc3, 0x6e, 0x6a, 0x5f, 0xf9,
0xb4, 0x0c, 0x1e, 0xdb, 0x5f, 0x5b, 0xc1, 0x37, 0xe0, 0x61, 0x26, 0xbc, 0x7a, 0x92, 0x8c, 0x49,
0x15, 0x65, 0x3b, 0xd3, 0xea, 0x06, 0x38, 0x4e, 0x60, 0x99, 0x04, 0xd3, 0x6f, 0x01, 0xf4, 0x9b,
0x71, 0x85, 0x25, 0x91, 0x49, 0x75, 0x3d, 0xb7, 0x9e, 0x8a, 0xea, 0x45, 0x39, 0x6b, 0x9d, 0x19,
0x73, 0x85, 0xcd, 0xba, 0xbf, 0x78, 0xf8, 0x08, 0xad, 0x3a, 0xf8, 0xf9, 0xf2, 0x55, 0x00, 0x00,
0x00, 0xff, 0xff, 0x58, 0xae, 0x00, 0xd6, 0xa0, 0x06, 0x00, 0x00,
}

View File

@@ -1,98 +0,0 @@
syntax = "proto3";
option go_package = "proto";
package plugins;
message TsdbQuery {
TimeRange timeRange = 1;
DatasourceInfo datasource = 2;
repeated Query queries = 3;
}
message Query {
string refId = 1;
int64 maxDataPoints = 2;
int64 intervalMs = 3;
string modelJson = 4;
}
message TimeRange {
string fromRaw = 1;
string toRaw = 2;
int64 fromEpochMs = 3;
int64 toEpochMs = 4;
}
message Response {
repeated QueryResult results = 1;
}
message QueryResult {
string error = 1;
string refId = 2;
string metaJson = 3;
repeated TimeSeries series = 4;
repeated Table tables = 5;
}
message Table {
repeated TableColumn columns = 1;
repeated TableRow rows = 2;
}
message TableColumn {
string name = 1;
}
message TableRow {
repeated RowValue values = 1;
}
message RowValue {
enum Kind {
// Field type null.
TYPE_NULL = 0;
// Field type double.
TYPE_DOUBLE = 1;
// Field type int64.
TYPE_INT64 = 2;
// Field type bool.
TYPE_BOOL = 3;
// Field type string.
TYPE_STRING = 4;
// Field type bytes.
TYPE_BYTES = 5;
};
Kind kind = 1;
double doubleValue = 2;
int64 int64Value = 3;
bool boolValue = 4;
string stringValue = 5;
bytes bytesValue = 6;
}
message DatasourceInfo {
int64 id = 1;
int64 orgId = 2;
string name = 3;
string type = 4;
string url = 5;
string jsonData = 6;
string secureJsonData = 7;
}
message TimeSeries {
string name = 1;
map<string, string> tags = 2;
repeated Point points = 3;
}
message Point {
int64 timestamp = 1;
double value = 2;
}
service TsdbPlugin {
rpc Query(TsdbQuery) returns (Response);
}