separate plugin impl and proto files
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"log"
|
||||
|
||||
shared "github.com/grafana/grafana/pkg/plugins/backend/shared"
|
||||
proto "github.com/grafana/grafana/pkg/tsdb/models"
|
||||
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,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user