Commit ce4beb73 by bergquist

Review tsdb protobuf contract

parent 1fd40a48
package tsdb
import (
"github.com/golang/protobuf/ptypes"
"github.com/grafana/grafana/pkg/components/null"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/tsdb"
......@@ -19,28 +18,20 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
return nil, err
}
now, err := ptypes.TimestampProto(query.TimeRange.Now)
if err != nil {
return nil, err
}
pbQuery := &proto.TsdbQuery{
Datasource: &proto.DatasourceInfo{
Access: string(ds.Access),
BasicAuth: ds.BasicAuth,
BasicAuthUser: ds.BasicAuthUser,
BasicAuthPassword: ds.BasicAuthPassword,
JsonData: string(jsonData),
Name: ds.Name,
Type: ds.Type,
Url: ds.Url,
Id: ds.Id,
OrgId: ds.OrgId,
JsonData: string(jsonData),
Name: ds.Name,
Type: ds.Type,
Url: ds.Url,
Id: ds.Id,
OrgId: ds.OrgId,
},
Timerange: &proto.Timerange{
From: query.TimeRange.From,
To: query.TimeRange.To,
Now: now,
TimeRange: &proto.TimeRange{
FromRaw: query.TimeRange.From,
ToRaw: query.TimeRange.To,
ToEpochMs: query.TimeRange.GetToAsMsEpoch(),
FromEpochMs: query.TimeRange.GetFromAsMsEpoch(),
},
Queries: []*proto.Query{},
}
......@@ -63,7 +54,6 @@ func (tw *DatasourcePluginWrapper) Query(ctx context.Context, ds *models.DataSou
}
res := &tsdb.Response{
Message: pbres.Message,
Results: map[string]*tsdb.QueryResult{},
}
......
......@@ -10,7 +10,7 @@ It is generated from these files:
It has these top-level messages:
TsdbQuery
Query
Timerange
TimeRange
Response
QueryResult
DatasourceInfo
......@@ -22,7 +22,6 @@ package proto
import proto1 "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import google_protobuf "github.com/golang/protobuf/ptypes/timestamp"
import (
context "golang.org/x/net/context"
......@@ -41,7 +40,7 @@ var _ = math.Inf
const _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package
type TsdbQuery struct {
Timerange *Timerange `protobuf:"bytes,1,opt,name=timerange" json:"timerange,omitempty"`
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"`
}
......@@ -51,9 +50,9 @@ func (m *TsdbQuery) String() string { return proto1.CompactTextString
func (*TsdbQuery) ProtoMessage() {}
func (*TsdbQuery) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *TsdbQuery) GetTimerange() *Timerange {
func (m *TsdbQuery) GetTimeRange() *TimeRange {
if m != nil {
return m.Timerange
return m.TimeRange
}
return nil
}
......@@ -74,9 +73,9 @@ func (m *TsdbQuery) GetQueries() []*Query {
type Query struct {
RefId string `protobuf:"bytes,1,opt,name=refId" json:"refId,omitempty"`
ModelJson string `protobuf:"bytes,2,opt,name=modelJson" json:"modelJson,omitempty"`
MaxDataPoints int64 `protobuf:"varint,3,opt,name=MaxDataPoints" json:"MaxDataPoints,omitempty"`
IntervalMs int64 `protobuf:"varint,4,opt,name=intervalMs" json:"intervalMs,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{} }
......@@ -91,13 +90,6 @@ func (m *Query) GetRefId() string {
return ""
}
func (m *Query) GetModelJson() string {
if m != nil {
return m.ModelJson
}
return ""
}
func (m *Query) GetMaxDataPoints() int64 {
if m != nil {
return m.MaxDataPoints
......@@ -112,41 +104,55 @@ func (m *Query) GetIntervalMs() int64 {
return 0
}
type Timerange struct {
From string `protobuf:"bytes,1,opt,name=from" json:"from,omitempty"`
To string `protobuf:"bytes,2,opt,name=to" json:"to,omitempty"`
Now *google_protobuf.Timestamp `protobuf:"bytes,3,opt,name=now" json:"now,omitempty"`
func (m *Query) GetModelJson() string {
if m != nil {
return m.ModelJson
}
return ""
}
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} }
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) GetFrom() string {
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.From
return m.FromRaw
}
return ""
}
func (m *Timerange) GetTo() string {
func (m *TimeRange) GetToRaw() string {
if m != nil {
return m.To
return m.ToRaw
}
return ""
}
func (m *Timerange) GetNow() *google_protobuf.Timestamp {
func (m *TimeRange) GetFromEpochMs() int64 {
if m != nil {
return m.Now
return m.FromEpochMs
}
return nil
return 0
}
func (m *TimeRange) GetToEpochMs() int64 {
if m != nil {
return m.ToEpochMs
}
return 0
}
type Response struct {
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
Results map[string]*QueryResult `protobuf:"bytes,2,rep,name=results" json:"results,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
Results []*QueryResult `protobuf:"bytes,1,rep,name=results" json:"results,omitempty"`
}
func (m *Response) Reset() { *m = Response{} }
......@@ -154,14 +160,7 @@ func (m *Response) String() string { return proto1.CompactTextString(
func (*Response) ProtoMessage() {}
func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *Response) GetMessage() string {
if m != nil {
return m.Message
}
return ""
}
func (m *Response) GetResults() map[string]*QueryResult {
func (m *Response) GetResults() []*QueryResult {
if m != nil {
return m.Results
}
......@@ -169,11 +168,10 @@ func (m *Response) GetResults() map[string]*QueryResult {
}
type QueryResult struct {
Error string `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"`
ErrorString string `protobuf:"bytes,2,opt,name=errorString" json:"errorString,omitempty"`
RefId string `protobuf:"bytes,3,opt,name=refId" json:"refId,omitempty"`
MetaJson string `protobuf:"bytes,4,opt,name=metaJson" json:"metaJson,omitempty"`
Series []*TimeSeries `protobuf:"bytes,5,rep,name=series" json:"series,omitempty"`
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"`
}
func (m *QueryResult) Reset() { *m = QueryResult{} }
......@@ -188,13 +186,6 @@ func (m *QueryResult) GetError() string {
return ""
}
func (m *QueryResult) GetErrorString() string {
if m != nil {
return m.ErrorString
}
return ""
}
func (m *QueryResult) GetRefId() string {
if m != nil {
return m.RefId
......@@ -217,17 +208,13 @@ func (m *QueryResult) GetSeries() []*TimeSeries {
}
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"`
Access string `protobuf:"bytes,5,opt,name=access" json:"access,omitempty"`
Url string `protobuf:"bytes,6,opt,name=url" json:"url,omitempty"`
BasicAuth bool `protobuf:"varint,7,opt,name=basicAuth" json:"basicAuth,omitempty"`
BasicAuthUser string `protobuf:"bytes,8,opt,name=basicAuthUser" json:"basicAuthUser,omitempty"`
BasicAuthPassword string `protobuf:"bytes,9,opt,name=basicAuthPassword" json:"basicAuthPassword,omitempty"`
JsonData string `protobuf:"bytes,10,opt,name=jsonData" json:"jsonData,omitempty"`
SecureJsonData string `protobuf:"bytes,11,opt,name=secureJsonData" json:"secureJsonData,omitempty"`
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{} }
......@@ -263,13 +250,6 @@ func (m *DatasourceInfo) GetType() string {
return ""
}
func (m *DatasourceInfo) GetAccess() string {
if m != nil {
return m.Access
}
return ""
}
func (m *DatasourceInfo) GetUrl() string {
if m != nil {
return m.Url
......@@ -277,27 +257,6 @@ func (m *DatasourceInfo) GetUrl() string {
return ""
}
func (m *DatasourceInfo) GetBasicAuth() bool {
if m != nil {
return m.BasicAuth
}
return false
}
func (m *DatasourceInfo) GetBasicAuthUser() string {
if m != nil {
return m.BasicAuthUser
}
return ""
}
func (m *DatasourceInfo) GetBasicAuthPassword() string {
if m != nil {
return m.BasicAuthPassword
}
return ""
}
func (m *DatasourceInfo) GetJsonData() string {
if m != nil {
return m.JsonData
......@@ -371,7 +330,7 @@ func (m *Point) GetValue() float64 {
func init() {
proto1.RegisterType((*TsdbQuery)(nil), "plugins.TsdbQuery")
proto1.RegisterType((*Query)(nil), "plugins.Query")
proto1.RegisterType((*Timerange)(nil), "plugins.Timerange")
proto1.RegisterType((*TimeRange)(nil), "plugins.TimeRange")
proto1.RegisterType((*Response)(nil), "plugins.Response")
proto1.RegisterType((*QueryResult)(nil), "plugins.QueryResult")
proto1.RegisterType((*DatasourceInfo)(nil), "plugins.DatasourceInfo")
......@@ -454,49 +413,41 @@ var _TsdbPlugin_serviceDesc = grpc.ServiceDesc{
func init() { proto1.RegisterFile("tsdb_plugin.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 691 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x54, 0xcd, 0x6e, 0xd3, 0x4c,
0x14, 0x95, 0xe3, 0xfc, 0xf9, 0xe6, 0xfb, 0x22, 0x3a, 0x54, 0x60, 0x45, 0x50, 0x22, 0x0b, 0x55,
0x11, 0x54, 0x2e, 0x84, 0x45, 0x2b, 0x60, 0x03, 0x82, 0x45, 0x2b, 0x55, 0x0a, 0xd3, 0xb2, 0x41,
0x42, 0x68, 0x12, 0x4f, 0x8c, 0xc1, 0xf6, 0x84, 0x99, 0x71, 0x4b, 0x97, 0xbc, 0x09, 0x0b, 0x1e,
0x80, 0x05, 0x6b, 0x9e, 0x0d, 0xcd, 0xf5, 0xd8, 0x71, 0xda, 0xae, 0x72, 0x7f, 0xce, 0x1d, 0x9f,
0x9c, 0x73, 0x67, 0x60, 0x4b, 0xab, 0x68, 0xfe, 0x69, 0x95, 0x16, 0x71, 0x92, 0x87, 0x2b, 0x29,
0xb4, 0x20, 0xbd, 0x32, 0x53, 0xa3, 0x07, 0xb1, 0x10, 0x71, 0xca, 0xf7, 0xb1, 0x3c, 0x2f, 0x96,
0xfb, 0x3a, 0xc9, 0xb8, 0xd2, 0x2c, 0x5b, 0x95, 0xc8, 0xe0, 0xa7, 0x03, 0xde, 0x99, 0x8a, 0xe6,
0xef, 0x0a, 0x2e, 0x2f, 0xc9, 0x13, 0xf0, 0x0c, 0x40,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0x00,
// 566 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x54, 0x51, 0x8b, 0xd3, 0x4c,
0x14, 0x25, 0x49, 0xdb, 0x6c, 0x6e, 0xf9, 0xca, 0xb7, 0xe3, 0x82, 0xa1, 0xa8, 0x94, 0x20, 0x4b,
0x41, 0x08, 0x5a, 0x1f, 0x56, 0x56, 0x9f, 0xc4, 0x7d, 0xd8, 0x05, 0x61, 0x1d, 0xfb, 0xe4, 0x8b,
0x4c, 0x9b, 0x69, 0x8c, 0x26, 0x99, 0x38, 0x33, 0x59, 0x2d, 0x3e, 0xe9, 0x2f, 0xf1, 0x47, 0xf8,
0x03, 0x65, 0x6e, 0x32, 0x49, 0x5a, 0x7c, 0xea, 0xdc, 0x73, 0xce, 0xcc, 0x3d, 0x39, 0x73, 0x3b,
0x70, 0xaa, 0x55, 0xb2, 0xf9, 0x58, 0xe5, 0x75, 0x9a, 0x95, 0x71, 0x25, 0x85, 0x16, 0xc4, 0x6f,
0x2a, 0x15, 0xfd, 0x76, 0x20, 0x58, 0xab, 0x64, 0xf3, 0xae, 0xe6, 0x72, 0x4f, 0x9e, 0x42, 0xa0,
0xb3, 0x82, 0x53, 0x56, 0xa6, 0x3c, 0x74, 0x16, 0xce, 0x72, 0xba, 0x22, 0x71, 0x2b, 0x8d, 0xd7,
0x96, 0xa1, 0xbd, 0x88, 0x5c, 0x00, 0x24, 0x4c, 0x33, 0x25, 0x6a, 0xb9, 0xe5, 0xa1, 0x8b, 0x5b,
0xee, 0x77, 0x5b, 0xde, 0x74, 0xd4, 0x75, 0xb9, 0x13, 0x74, 0x20, 0x25, 0x4b, 0xf0, 0xbf, 0xd6,
0x5c, 0x66, 0x5c, 0x85, 0xde, 0xc2, 0x5b, 0x4e, 0x57, 0xb3, 0x6e, 0x17, 0x7a, 0xa1, 0x96, 0x8e,
0x7e, 0x3a, 0x30, 0x6e, 0xec, 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 0xfe, 0x37, 0x00, 0x00, 0xff, 0xff, 0xbf, 0x69,
0x3b, 0x74, 0x7b, 0x04, 0x00, 0x00,
}
......@@ -3,39 +3,35 @@ option go_package = "proto";
package plugins;
import "google/protobuf/timestamp.proto";
message TsdbQuery {
Timerange timerange = 1;
TimeRange timeRange = 1;
DatasourceInfo datasource = 2;
repeated Query queries = 3;
}
message Query {
string refId = 1;
string modelJson = 2;
int64 MaxDataPoints = 3;
int64 intervalMs = 4;
// dont repeat. DatasourceInfo datasource = 5;
int64 maxDataPoints = 2;
int64 intervalMs = 3;
string modelJson = 4;
}
message Timerange {
string from = 1;
string to = 2;
google.protobuf.Timestamp now = 3;
message TimeRange {
string fromRaw = 1;
string toRaw = 2;
int64 fromEpochMs = 3;
int64 toEpochMs = 4;
}
message Response {
string message = 1;
map<string, QueryResult> results = 2;
repeated QueryResult results = 1;
}
message QueryResult {
string error = 1;
string errorString = 2;
string refId = 3;
string metaJson = 4;
repeated TimeSeries series = 5;
string refId = 2;
string metaJson = 3;
repeated TimeSeries series = 4;
//repeat Table tables = x;
}
......@@ -45,13 +41,9 @@ message DatasourceInfo {
int64 orgId = 2;
string name = 3;
string type = 4;
string access = 5;
string url = 6;
bool basicAuth = 7;
string basicAuthUser = 8;
string basicAuthPassword = 9;
string jsonData = 10;
string secureJsonData = 11;
string url = 5;
string jsonData = 6;
string secureJsonData = 7;
}
message TimeSeries {
......
......@@ -11,14 +11,14 @@ func NewTimeRange(from, to string) *TimeRange {
return &TimeRange{
From: from,
To: to,
Now: time.Now(),
now: time.Now(),
}
}
type TimeRange struct {
From string
To string
Now time.Time
now time.Time
}
func (tr *TimeRange) GetFromAsMsEpoch() int64 {
......@@ -65,12 +65,12 @@ func (tr *TimeRange) ParseFrom() (time.Time, error) {
return time.Time{}, err
}
return tr.Now.Add(diff), nil
return tr.now.Add(diff), nil
}
func (tr *TimeRange) ParseTo() (time.Time, error) {
if tr.To == "now" {
return tr.Now, nil
return tr.now, nil
} else if strings.HasPrefix(tr.To, "now-") {
withoutNow := strings.Replace(tr.To, "now-", "", 1)
......@@ -79,7 +79,7 @@ func (tr *TimeRange) ParseTo() (time.Time, error) {
return time.Time{}, nil
}
return tr.Now.Add(diff), nil
return tr.now.Add(diff), nil
}
if res, ok := tryParseUnixMsEpoch(tr.To); ok {
......
......@@ -16,7 +16,7 @@ func TestTimeRange(t *testing.T) {
tr := TimeRange{
From: "5m",
To: "now",
Now: now,
now: now,
}
Convey("5m ago ", func() {
......@@ -39,7 +39,7 @@ func TestTimeRange(t *testing.T) {
tr := TimeRange{
From: "5h",
To: "now-10m",
Now: now,
now: now,
}
Convey("5h ago ", func() {
......@@ -65,7 +65,7 @@ func TestTimeRange(t *testing.T) {
tr := TimeRange{
From: "1474973725473",
To: "1474975757930",
Now: now,
now: now,
}
res, err := tr.ParseFrom()
......@@ -82,7 +82,7 @@ func TestTimeRange(t *testing.T) {
tr := TimeRange{
From: "asdf",
To: "asdf",
Now: now,
now: now,
}
_, err = tr.ParseFrom()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment