Bläddra i källkod

Adds Table in backend datasource contract.

Leonard Gram 8 år sedan
förälder
incheckning
b63c834a4b

+ 68 - 1
pkg/plugins/datasource/tsdb/datasource_plugin_wrapper.go

@@ -1,15 +1,23 @@
 package tsdb
 
 import (
+	"fmt"
 	"github.com/grafana/grafana/pkg/components/null"
+	"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"
 	"golang.org/x/net/context"
 )
 
+func NewDatasourcePluginWrapper(log log.Logger, plugin TsdbPlugin) *DatasourcePluginWrapper {
+	return &DatasourcePluginWrapper{TsdbPlugin: plugin, logger: log}
+}
+
 type DatasourcePluginWrapper struct {
 	TsdbPlugin
+
+	logger log.Logger
 }
 
 func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSource, query *tsdb.TsdbQuery) (*tsdb.Response, error) {
@@ -63,7 +71,7 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
 			Series: []*tsdb.TimeSeries{},
 		}
 
-		for _, s := range r.Series {
+		for _, s := range r.GetSeries() {
 			points := tsdb.TimeSeriesPoints{}
 
 			for _, p := range s.Points {
@@ -77,7 +85,66 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
 				Points: points,
 			})
 		}
+
+		mappedTables, err := tw.mapTables(r)
+		if err != nil {
+			return nil, err
+		}
+		res.Results[r.RefId].Tables = mappedTables
 	}
 
 	return res, nil
 }
+func (tw *DatasourcePluginWrapper) mapTables(r *proto.QueryResult) ([]*tsdb.Table, error) {
+	var tables []*tsdb.Table
+	for _, t := range r.GetTables() {
+		mappedTable, err := tw.mapTable(t)
+		if err != nil {
+			return nil, err
+		}
+		tables = append(tables, mappedTable)
+	}
+	return tables, nil
+}
+
+func (tw *DatasourcePluginWrapper) mapTable(t *proto.Table) (*tsdb.Table, error) {
+	table := &tsdb.Table{}
+	for _, c := range t.GetColumns() {
+		table.Columns = append(table.Columns, tsdb.TableColumn{
+			Text: c.Name,
+		})
+	}
+
+	for _, r := range t.GetRows() {
+		row := tsdb.RowValues{}
+		for _, rv := range r.Values {
+			mappedRw, err := tw.mapRowValue(rv)
+			if err != nil {
+				return nil, err
+			}
+
+			row = append(row, mappedRw)
+		}
+		table.Rows = append(table.Rows, row)
+	}
+
+	return table, nil
+}
+func (tw *DatasourcePluginWrapper) mapRowValue(rv *proto.RowValue) (interface{}, error) {
+	switch rv.Kind {
+	case proto.RowValue_TYPE_NULL:
+		return nil, nil
+	case proto.RowValue_TYPE_INT64:
+		return rv.Int64Value, nil
+	case proto.RowValue_TYPE_BOOL:
+		return rv.BoolValue, nil
+	case proto.RowValue_TYPE_STRING:
+		return rv.StringValue, nil
+	case proto.RowValue_TYPE_DOUBLE:
+		return rv.DoubleValue, nil
+	case proto.RowValue_TYPE_BYTES:
+		return rv.BytesValue, nil
+	default:
+		return nil, fmt.Errorf("Unsupported row value %v from plugin", rv.Kind)
+	}
+}

+ 108 - 0
pkg/plugins/datasource/tsdb/datasource_plugin_wrapper_test.go

@@ -0,0 +1,108 @@
+package tsdb
+
+import (
+	"github.com/grafana/grafana/pkg/log"
+	"github.com/grafana/grafana/pkg/tsdb"
+	"github.com/grafana/grafana/pkg/tsdb/models"
+	"testing"
+)
+
+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{},
+		Rows:    nil,
+	})
+	want := []*tsdb.Table{{}}
+
+	have, err := dpw.mapTables(qr)
+	if err != nil {
+		t.Errorf("failed to map tables. error: %v", err)
+	}
+	if len(want) != len(have) {
+		t.Errorf("could not map all tables")
+	}
+}
+
+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{
+				{
+					Kind:      proto.RowValue_TYPE_BOOL,
+					BoolValue: true,
+				},
+				{
+					Kind:       proto.RowValue_TYPE_INT64,
+					Int64Value: 42,
+				},
+			},
+		}},
+	}
+
+	want := &tsdb.Table{
+		Columns: []tsdb.TableColumn{{Text: "column1"}, {Text: "column2"}},
+	}
+	have, err := dpw.mapTable(source)
+	if err != nil {
+		t.Fatalf("failed to map table. error: %v", err)
+	}
+
+	for i := range have.Columns {
+		if want.Columns[i] != have.Columns[i] {
+			t.Fatalf("have column: %s, want %s", have, want)
+		}
+	}
+
+	if len(have.Rows) != 1 {
+		t.Fatalf("Expects one row but got %d", len(have.Rows))
+	}
+
+	rowValuesCount := len(have.Rows[0])
+	if rowValuesCount != 2 {
+		t.Fatalf("Expects two row values, got %d", rowValuesCount)
+	}
+}
+
+func TestMappingRowValue(t *testing.T) {
+	dpw := NewDatasourcePluginWrapper(log.New("test-logger"), nil)
+
+	boolRowValue, _ := dpw.mapRowValue(&proto.RowValue{Kind: proto.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})
+	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"})
+	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})
+	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}})
+	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})
+	if haveNil != nil {
+		t.Fatalf("Expected %v, was %v", nil, haveNil)
+	}
+}

+ 1 - 1
pkg/plugins/datasource_plugin.go

@@ -111,7 +111,7 @@ func (p *DataSourcePlugin) spawnSubProcess() error {
 	plugin := raw.(shared.TsdbPlugin)
 
 	tsdb.RegisterTsdbQueryEndpoint(p.Id, func(dsInfo *models.DataSource) (tsdb.TsdbQueryEndpoint, error) {
-		return &shared.DatasourcePluginWrapper{TsdbPlugin: plugin}, nil
+		return shared.NewDatasourcePluginWrapper(p.log, plugin), nil
 	})
 
 	return nil

+ 155 - 49
pkg/tsdb/models/tsdb_plugin.pb.go

@@ -16,6 +16,7 @@ It has these top-level messages:
 	Table
 	TableColumn
 	TableRow
+	RowValue
 	DatasourceInfo
 	TimeSeries
 	Point
@@ -25,7 +26,6 @@ package proto
 import proto1 "github.com/golang/protobuf/proto"
 import fmt "fmt"
 import math "math"
-import google_protobuf "github.com/golang/protobuf/ptypes/any"
 
 import (
 	context "golang.org/x/net/context"
@@ -43,6 +43,45 @@ var _ = math.Inf
 // 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"`
@@ -260,7 +299,7 @@ func (m *TableColumn) GetName() string {
 }
 
 type TableRow struct {
-	Values []*google_protobuf.Any `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"`
+	Values []*RowValue `protobuf:"bytes,1,rep,name=values" json:"values,omitempty"`
 }
 
 func (m *TableRow) Reset()                    { *m = TableRow{} }
@@ -268,13 +307,69 @@ func (m *TableRow) String() string            { return proto1.CompactTextString(
 func (*TableRow) ProtoMessage()               {}
 func (*TableRow) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
 
-func (m *TableRow) GetValues() []*google_protobuf.Any {
+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"`
@@ -288,7 +383,7 @@ type DatasourceInfo struct {
 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{8} }
+func (*DatasourceInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
 
 func (m *DatasourceInfo) GetId() int64 {
 	if m != nil {
@@ -348,7 +443,7 @@ type TimeSeries struct {
 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{9} }
+func (*TimeSeries) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
 
 func (m *TimeSeries) GetName() string {
 	if m != nil {
@@ -379,7 +474,7 @@ type Point struct {
 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{10} }
+func (*Point) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
 
 func (m *Point) GetTimestamp() int64 {
 	if m != nil {
@@ -404,9 +499,11 @@ func init() {
 	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.
@@ -484,47 +581,56 @@ var _TsdbPlugin_serviceDesc = grpc.ServiceDesc{
 func init() { proto1.RegisterFile("tsdb_plugin.proto", fileDescriptor0) }
 
 var fileDescriptor0 = []byte{
-	// 665 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x54, 0x4d, 0x6f, 0xd4, 0x30,
-	0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0x52, 0x6d, 0xc5, 0xf3, 0x72, 0x18, 0x37, 0x87, 0x1b, 0xc7, 0x91, 0x56, 0xe8, 0xe4, 0x08,
-	0x86, 0xf5, 0x52, 0x7b, 0xc1, 0x6f, 0x7c, 0x55, 0x1d, 0x6d, 0x7f, 0xad, 0x61, 0xe8, 0xae, 0xeb,
-	0x4b, 0x0c, 0x4e, 0x3a, 0xc7, 0x5e, 0xf8, 0x02, 0x7a, 0xb8, 0x13, 0x8e, 0x4e, 0x92, 0x71, 0x6d,
-	0x58, 0x96, 0x57, 0x56, 0x37, 0x89, 0xf5, 0x0d, 0xbc, 0x6a, 0x83, 0xc3, 0x97, 0x00, 0xf6, 0xcd,
-	0xbb, 0x40, 0x49, 0x24, 0x72, 0xcf, 0x4b, 0xeb, 0xa9, 0x73, 0x2f, 0xe2, 0xa4, 0xe9, 0x25, 0x37,
-	0x82, 0xaf, 0x07, 0x1f, 0x7b, 0x65, 0x03, 0xf4, 0xf1, 0xf3, 0xfc, 0x5f, 0x00, 0x00, 0x00, 0xff,
-	0xff, 0xa8, 0xec, 0x66, 0xef, 0x7b, 0x05, 0x00, 0x00,
+	// 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, 0x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3a, 0xf8, 0xf9, 0xf2, 0x55, 0x00, 0x00,
+	0x00, 0xff, 0xff, 0x58, 0xae, 0x00, 0xd6, 0xa0, 0x06, 0x00, 0x00,
 }

+ 25 - 3
pkg/tsdb/models/tsdb_plugin.proto

@@ -3,8 +3,6 @@ option go_package = "proto";
 
 package plugins;
 
-import "google/protobuf/any.proto";
-
 message TsdbQuery {
   TimeRange timeRange = 1;
   DatasourceInfo datasource = 2;
@@ -47,7 +45,31 @@ message TableColumn {
 }
 
 message TableRow {
-  repeated google.protobuf.Any values = 1;
+  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 {