forked from oracle/oci-grafana-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.go
39 lines (32 loc) · 1.08 KB
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright © 2019 Oracle and/or its affiliates. All rights reserved.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
package main
import (
"github.com/grafana/grafana_plugin_model/go/datasource"
hclog "github.com/hashicorp/go-hclog"
plugin "github.com/hashicorp/go-plugin"
)
var pluginLogger = hclog.New(&hclog.LoggerOptions{
Name: "simple-json-datasource",
Level: hclog.LevelFromString("DEBUG"),
})
func main() {
pluginLogger.Debug("Running GRPC server")
// fetch all out variables
ociDatasource, err := NewOCIDatasource(pluginLogger)
if err != nil {
pluginLogger.Error("Unable to create plugin")
}
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "grafana_plugin_type",
MagicCookieValue: "datasource",
},
Plugins: map[string]plugin.Plugin{
"backend-datasource": &datasource.DatasourcePluginImpl{Plugin: ociDatasource},
},
// A non-nil value here enables gRPC serving for this plugin...
GRPCServer: plugin.DefaultGRPCServer,
})
}