initial version of proto files

This commit is contained in:
bergquist 2017-09-20 13:54:45 +02:00
parent 7b81ebc991
commit a97360ab27
5 changed files with 359 additions and 0 deletions

16
pkg/tsdb/plugins/generate.sh Executable file
View File

@ -0,0 +1,16 @@
#/bin/sh
#protoc -I/usr/local/include -I. \
# -I$GOPATH/src \
# -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
# --go_out=google/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \
# pb/service.proto
#protoc -I/usr/local/include -I. \
# -I$GOPATH/src \
# -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
# --go_out=google/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \
# pb/service.proto
protoc -I proto/ proto/tsdb_plugin.proto --go_out=plugins=grpc:tsdb_plugin

View File

@ -0,0 +1,252 @@
// 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:
TsdbRequest
TsdbQuery
TsdbResponse
TsdbSeries
*/
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
// Message represents a simple message sent to the Echo service.
type TsdbRequest struct {
From int64 `protobuf:"varint,1,opt,name=from" json:"from,omitempty"`
To int64 `protobuf:"varint,2,opt,name=to" json:"to,omitempty"`
Queries []*TsdbQuery `protobuf:"bytes,3,rep,name=queries" json:"queries,omitempty"`
}
func (m *TsdbRequest) Reset() { *m = TsdbRequest{} }
func (m *TsdbRequest) String() string { return proto1.CompactTextString(m) }
func (*TsdbRequest) ProtoMessage() {}
func (*TsdbRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *TsdbRequest) GetFrom() int64 {
if m != nil {
return m.From
}
return 0
}
func (m *TsdbRequest) GetTo() int64 {
if m != nil {
return m.To
}
return 0
}
func (m *TsdbRequest) GetQueries() []*TsdbQuery {
if m != nil {
return m.Queries
}
return nil
}
type TsdbQuery struct {
QueryJson string `protobuf:"bytes,1,opt,name=queryJson" json:"queryJson,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{1} }
func (m *TsdbQuery) GetQueryJson() string {
if m != nil {
return m.QueryJson
}
return ""
}
type TsdbResponse 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 []*TsdbSeries `protobuf:"bytes,5,rep,name=series" json:"series,omitempty"`
}
func (m *TsdbResponse) Reset() { *m = TsdbResponse{} }
func (m *TsdbResponse) String() string { return proto1.CompactTextString(m) }
func (*TsdbResponse) ProtoMessage() {}
func (*TsdbResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *TsdbResponse) GetError() string {
if m != nil {
return m.Error
}
return ""
}
func (m *TsdbResponse) GetErrorString() string {
if m != nil {
return m.ErrorString
}
return ""
}
func (m *TsdbResponse) GetRefId() string {
if m != nil {
return m.RefId
}
return ""
}
func (m *TsdbResponse) GetMetaJson() string {
if m != nil {
return m.MetaJson
}
return ""
}
func (m *TsdbResponse) GetSeries() []*TsdbSeries {
if m != nil {
return m.Series
}
return nil
}
type TsdbSeries struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (m *TsdbSeries) Reset() { *m = TsdbSeries{} }
func (m *TsdbSeries) String() string { return proto1.CompactTextString(m) }
func (*TsdbSeries) ProtoMessage() {}
func (*TsdbSeries) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *TsdbSeries) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func init() {
proto1.RegisterType((*TsdbRequest)(nil), "plugins.TsdbRequest")
proto1.RegisterType((*TsdbQuery)(nil), "plugins.TsdbQuery")
proto1.RegisterType((*TsdbResponse)(nil), "plugins.TsdbResponse")
proto1.RegisterType((*TsdbSeries)(nil), "plugins.TsdbSeries")
}
// 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 {
Get(ctx context.Context, in *TsdbRequest, opts ...grpc.CallOption) (*TsdbResponse, error)
}
type tsdbPluginClient struct {
cc *grpc.ClientConn
}
func NewTsdbPluginClient(cc *grpc.ClientConn) TsdbPluginClient {
return &tsdbPluginClient{cc}
}
func (c *tsdbPluginClient) Get(ctx context.Context, in *TsdbRequest, opts ...grpc.CallOption) (*TsdbResponse, error) {
out := new(TsdbResponse)
err := grpc.Invoke(ctx, "/plugins.TsdbPlugin/Get", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for TsdbPlugin service
type TsdbPluginServer interface {
Get(context.Context, *TsdbRequest) (*TsdbResponse, error)
}
func RegisterTsdbPluginServer(s *grpc.Server, srv TsdbPluginServer) {
s.RegisterService(&_TsdbPlugin_serviceDesc, srv)
}
func _TsdbPlugin_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TsdbRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TsdbPluginServer).Get(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/plugins.TsdbPlugin/Get",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TsdbPluginServer).Get(ctx, req.(*TsdbRequest))
}
return interceptor(ctx, in, info, handler)
}
var _TsdbPlugin_serviceDesc = grpc.ServiceDesc{
ServiceName: "plugins.TsdbPlugin",
HandlerType: (*TsdbPluginServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Get",
Handler: _TsdbPlugin_Get_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "tsdb_plugin.proto",
}
func init() { proto1.RegisterFile("tsdb_plugin.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 280 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x51, 0xc1, 0x4e, 0x83, 0x40,
0x10, 0x0d, 0x50, 0x8a, 0x0c, 0xc6, 0xc4, 0xb1, 0x26, 0xa4, 0xf1, 0x40, 0x38, 0xd5, 0x68, 0x38,
0xe0, 0x0f, 0x18, 0x2f, 0x46, 0x4f, 0xba, 0xf5, 0xe4, 0xa5, 0x29, 0x61, 0xda, 0x90, 0x08, 0x4b,
0x77, 0x97, 0x43, 0x3f, 0xc8, 0xff, 0x34, 0xcc, 0xae, 0xad, 0xf5, 0xc4, 0xbc, 0xb7, 0x6f, 0xde,
0xcc, 0x1b, 0xe0, 0xd2, 0xe8, 0xba, 0x5a, 0xf5, 0x5f, 0xc3, 0xb6, 0xe9, 0x8a, 0x5e, 0x49, 0x23,
0x31, 0xb2, 0x48, 0xe7, 0x2b, 0x48, 0x3e, 0x74, 0x5d, 0x09, 0xda, 0x0d, 0xa4, 0x0d, 0x22, 0x4c,
0x36, 0x4a, 0xb6, 0xa9, 0x97, 0x79, 0x8b, 0x40, 0x70, 0x8d, 0x17, 0xe0, 0x1b, 0x99, 0xfa, 0xcc,
0xf8, 0x46, 0xe2, 0x3d, 0x44, 0xbb, 0x81, 0x54, 0x43, 0x3a, 0x0d, 0xb2, 0x60, 0x91, 0x94, 0x58,
0x38, 0xb7, 0x62, 0xb4, 0x7a, 0x1f, 0x48, 0xed, 0xc5, 0xaf, 0x24, 0xbf, 0x85, 0xf8, 0xc0, 0xe2,
0x0d, 0xc4, 0x23, 0xbf, 0x7f, 0xd5, 0xb2, 0xe3, 0x19, 0xb1, 0x38, 0x12, 0xf9, 0xb7, 0x07, 0xe7,
0x76, 0x19, 0xdd, 0xcb, 0x4e, 0x13, 0xce, 0x20, 0x24, 0xa5, 0xa4, 0x72, 0x52, 0x0b, 0x30, 0x83,
0x84, 0x8b, 0xa5, 0x51, 0x4d, 0xb7, 0xe5, 0xc5, 0x62, 0xf1, 0x97, 0x1a, 0xfb, 0x14, 0x6d, 0x5e,
0xea, 0x34, 0xb0, 0x7d, 0x0c, 0x70, 0x0e, 0x67, 0x2d, 0x99, 0x35, 0xcf, 0x9e, 0xf0, 0xc3, 0x01,
0xe3, 0x1d, 0x4c, 0xb5, 0x8d, 0x14, 0x72, 0xa4, 0xab, 0x93, 0x48, 0x4b, 0x7e, 0x12, 0x4e, 0x92,
0x67, 0x00, 0x47, 0x76, 0x3c, 0x59, 0xb7, 0x6e, 0xc9, 0xed, 0xc8, 0x75, 0xf9, 0x68, 0x15, 0x6f,
0xec, 0x81, 0x25, 0x04, 0xcf, 0x64, 0x70, 0x76, 0xe2, 0xe9, 0x2e, 0x3e, 0xbf, 0xfe, 0xc7, 0xda,
0xe8, 0x4f, 0xd1, 0x67, 0xc8, 0x7f, 0xaa, 0x9a, 0xf2, 0xe7, 0xe1, 0x27, 0x00, 0x00, 0xff, 0xff,
0x11, 0xda, 0x61, 0xe4, 0xc5, 0x01, 0x00, 0x00,
}

View File

@ -0,0 +1,32 @@
syntax = "proto3";
option go_package = "proto";
package plugins;
// Message represents a simple message sent to the Echo service.
message TsdbRequest {
int64 from = 1;
int64 to = 2;
repeated TsdbQuery queries = 3;
}
message TsdbQuery {
string queryJson = 1;
}
message TsdbResponse {
string error = 1;
string errorString = 2;
string refId = 3;
string metaJson = 4;
repeated TsdbSeries series = 5;
//repeat TsdbTables tables = x;
}
message TsdbSeries {
string name = 1;
}
service TsdbPlugin {
rpc Get(TsdbRequest) returns (TsdbResponse);
}

View File

@ -0,0 +1,22 @@
package shared
import (
proto "github.com/grafana/grafana/pkg/tsdb/plugins/proto"
"golang.org/x/net/context"
)
type GRPCClient struct {
proto.TsdbPluginClient
}
func (m *GRPCClient) Get(ctx context.Context, req *proto.TsdbRequest) (*proto.TsdbResponse, error) {
return m.TsdbPluginClient.Get(ctx, req)
}
type GRPCServer struct {
TsdbPlugin
}
func (m *GRPCServer) Get(ctx context.Context, req *proto.TsdbRequest) (*proto.TsdbResponse, error) {
return m.TsdbPlugin.Get(ctx, req)
}

View File

@ -0,0 +1,37 @@
package shared
import (
"golang.org/x/net/context"
proto "github.com/grafana/grafana/pkg/tsdb/plugins/proto"
plugin "github.com/hashicorp/go-plugin"
"google.golang.org/grpc"
)
var PluginMap = map[string]plugin.Plugin{
"tsdb_mock": &TsdbPluginImpl{},
}
var Handshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "BASIC_PLUGIN",
MagicCookieValue: "hello",
}
type TsdbPlugin interface {
Get(ctx context.Context, req *proto.TsdbRequest) (*proto.TsdbResponse, error)
}
type TsdbPluginImpl struct { //LOL IMPL LOL
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
}