experimental

package
v0.50.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2020 License: Apache-2.0 Imports: 7 Imported by: 5

Documentation

Overview

Package experimental is a place where we include interfaces and structures that may be useful, but require additional testing and feedback before we think they should be added to the main SDK. The features in this package may change without notice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MainXYZ

func MainXYZ()

func SendJSON

func SendJSON(sender backend.CallResourceResponseSender, obj interface{}) error

SendJSON sends a JSON object.

func SendPlainText

func SendPlainText(sender backend.CallResourceResponseSender, text string) error

SendPlainText sends a plain text snippet.

func SendResourceResponse

func SendResourceResponse(
	sender backend.CallResourceResponseSender,
	status int,
	headers map[string][]string,
	body []byte,
) error

SendResourceResponse sends a JSON object.

Types

type DataSourceInstance

type DataSourceInstance interface {
	CheckHealth() *backend.CheckHealthResult

	// If the request does not need access to the headers or user, use this request
	QueryData(req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)

	// CallResource calls a resource.
	CallResource(req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error

	// Destroy lets you clean up any instance variables when the settings change
	Destroy()
}

DataSourceInstance implements each of the supported requests. Alternatively this could be a set of interfaces that work for DataSource|AlertNotifier|etc|etc... with the support interrogated and maintained by the helper on startup.

type InstanceManager

type InstanceManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

InstanceManager is a singleton that holds all datasource instances

func NewInstanceManager

func NewInstanceManager(host PluginHost) *InstanceManager

NewInstanceManager creates a new instance manager.

func (*InstanceManager) CallResource

CallResource calls a resource.

func (*InstanceManager) CheckHealth

CheckHealth checks if the plugin is running properly

func (*InstanceManager) QueryData

QueryData queries for data.

func (*InstanceManager) RunGRPCServer

func (p *InstanceManager) RunGRPCServer() error

RunGRPCServer starts the GRPC server

type MyDataSourceInstance

type MyDataSourceInstance struct {
	// contains filtered or unexported fields
}

MyDataSourceInstance implements backend.DataSourceInstance

func (*MyDataSourceInstance) CallResource

CallResource HTTP style resource

func (*MyDataSourceInstance) CheckHealth

func (ds *MyDataSourceInstance) CheckHealth() *backend.CheckHealthResult

CheckHealth will check the currently configured settings

func (*MyDataSourceInstance) Destroy

func (ds *MyDataSourceInstance) Destroy()

Destroy destroy an instance (if necessary)

func (*MyDataSourceInstance) QueryData

QueryData will run a set of queries

type MyHost

type MyHost struct{}

MyHost is a singleton host service.

func (*MyHost) CheckHostHealth

func (ds *MyHost) CheckHostHealth(config backend.PluginConfig) *backend.CheckHealthResult

CheckHostHealth returns a backend.CheckHealthResult.

func (*MyHost) NewDataSourceInstance

func (ds *MyHost) NewDataSourceInstance(config backend.PluginConfig) (DataSourceInstance, error)

NewDataSourceInstance creates a new datasource instance.

type PluginHost

type PluginHost interface {
	// CheckExeHealth corresponds to CheckHostHealth for the plugin executable.
	CheckHostHealth(config backend.PluginConfig) *backend.CheckHealthResult

	// NewDataSourceInstance makes a request for a new datasource.
	NewDataSourceInstance(config backend.PluginConfig) (DataSourceInstance, error)
}

PluginHost is the singleton container for your plugin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL