backend

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2020 License: Apache-2.0 Imports: 11 Imported by: 301

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger log.Logger = log.New()

Logger is the default logger instance.

Functions

func Serve

func Serve(opts ServeOpts) error

Serve starts serving the plugin over gRPC.

Types

type CallResourceHandler

type CallResourceHandler interface {
	CallResource(ctx context.Context, req *CallResourceRequest, sender CallResourceResponseSender) error
}

CallResourceHandler handles resource calls.

type CallResourceRequest

type CallResourceRequest struct {
	PluginConfig PluginConfig
	Path         string
	Method       string
	URL          string
	Headers      map[string][]string
	Body         []byte
	User         *User
}

type CallResourceResponse

type CallResourceResponse struct {
	Status  int
	Headers map[string][]string
	Body    []byte
}

type CallResourceResponseSender

type CallResourceResponseSender interface {
	Send(*CallResourceResponse) error
}

CallResourceResponseSender used for sending resource call responses.

type CheckHealthHandler

type CheckHealthHandler interface {
	CheckHealth(ctx context.Context, req *CheckHealthRequest) (*CheckHealthResult, error)
}

CheckHealthHandler enables users to send health check requests to a backend plugin

type CheckHealthRequest

type CheckHealthRequest struct {
	PluginConfig PluginConfig
}

CheckHealthRequest contains the healthcheck request

type CheckHealthResult

type CheckHealthResult struct {
	Status      HealthStatus
	Message     string
	JSONDetails string
}

CheckHealthResult contains the healthcheck response

type DataQuery

type DataQuery struct {
	RefID         string
	MaxDataPoints int64
	Interval      time.Duration
	TimeRange     TimeRange
	JSON          json.RawMessage
}

DataQuery represents the query as sent from the frontend.

type DataSourceConfig

type DataSourceConfig struct {
	ID                      int64
	Name                    string
	URL                     string
	User                    string
	Database                string
	BasicAuthEnabled        bool
	BasicAuthUser           string
	JSONData                json.RawMessage
	DecryptedSecureJSONData map[string]string
	Updated                 time.Time
}

DataSourceConfig configuration for a datasource plugin.

type HealthStatus

type HealthStatus int

HealthStatus is the status of the plugin.

const (
	// HealthStatusUnknown means the status of the plugin is unknown.
	HealthStatusUnknown HealthStatus = iota
	// HealthStatusOk means the status of the plugin is good.
	HealthStatusOk
	// HealthStatusError means the plugin is in an error state.
	HealthStatusError
)

type PluginConfig

type PluginConfig struct {
	OrgID                   int64
	PluginID                string
	JSONData                json.RawMessage
	DecryptedSecureJSONData map[string]string
	Updated                 time.Time
	DataSourceConfig        *DataSourceConfig
}

PluginConfig configuration for a plugin.

type QueryDataHandler

type QueryDataHandler interface {
	QueryData(ctx context.Context, req *QueryDataRequest) (*QueryDataResponse, error)
}

QueryDataHandler handles data queries.

type QueryDataRequest

type QueryDataRequest struct {
	PluginConfig PluginConfig
	Headers      map[string]string
	Queries      []DataQuery
	User         *User
}

type QueryDataResponse

type QueryDataResponse struct {
	Frames   []*data.Frame
	Metadata map[string]string
}

QueryDataResponse holds the results for a given query.

type ServeOpts

type ServeOpts struct {
	CheckHealthHandler   CheckHealthHandler
	CallResourceHandler  CallResourceHandler
	QueryDataHandler     QueryDataHandler
	TransformDataHandler TransformDataHandler
}

ServeOpts options for serving plugins.

type TimeRange

type TimeRange struct {
	From time.Time
	To   time.Time
}

TimeRange represents a time range for a query.

type TransformDataCallBackHandler

type TransformDataCallBackHandler interface {
	// TODO: Forget if I actually need PluginConfig on the callback or not.
	QueryData(ctx context.Context, req *QueryDataRequest) (*QueryDataResponse, error)
}

type TransformDataHandler

type TransformDataHandler interface {
	TransformData(ctx context.Context, req *QueryDataRequest, callBack TransformDataCallBackHandler) (*QueryDataResponse, error)
}

type TransformHandlers

type TransformHandlers interface {
	TransformDataHandler
}

type User

type User struct {
	Login string
	Name  string
	Email string
	Role  string
}

User represents the Grafana user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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