2017-09-20 17:08:09 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
|
|
|
|
|
|
"log"
|
|
|
|
|
|
2017-09-21 17:02:40 +02:00
|
|
|
shared "github.com/grafana/grafana/pkg/plugins/backend/shared"
|
|
|
|
|
proto "github.com/grafana/grafana/pkg/tsdb/models"
|
2017-09-20 17:08:09 +02:00
|
|
|
plugin "github.com/hashicorp/go-plugin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Tsdb struct {
|
|
|
|
|
plugin.NetRPCUnsupportedPlugin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Tsdb) Get(ctx context.Context, req *proto.TsdbRequest) (*proto.TsdbResponse, error) {
|
|
|
|
|
log.Print("Tsdb.Get() from plugin")
|
|
|
|
|
|
|
|
|
|
return &proto.TsdbResponse{
|
|
|
|
|
MetaJson: "from plugins! meta meta",
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
plugin.Serve(&plugin.ServeConfig{
|
|
|
|
|
HandshakeConfig: plugin.HandshakeConfig{
|
|
|
|
|
ProtocolVersion: 1,
|
|
|
|
|
MagicCookieKey: "BASIC_PLUGIN",
|
|
|
|
|
MagicCookieValue: "hello",
|
|
|
|
|
},
|
|
|
|
|
Plugins: map[string]plugin.Plugin{
|
|
|
|
|
"tsdb_mock": &shared.TsdbPluginImpl{Plugin: &Tsdb{}},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// A non-nil value here enables gRPC serving for this plugin...
|
|
|
|
|
GRPCServer: plugin.DefaultGRPCServer,
|
|
|
|
|
})
|
|
|
|
|
}
|