plugin

package
v0.0.0-...-8b3eb0f Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHealth

CheckHealth ensures that the datasource settings are able to retrieve data from GitLab.

func GetDatasourceOpts

func GetDatasourceOpts() datasource.ServeOpts

GetDatasourceOpts returns the datasource.ServeOpts for this plugin.

func GetQueryHandlers

func GetQueryHandlers(s *Server) *datasource.QueryTypeMux

GetQueryHandlers creates the QueryTypeMux type for handling queries

func HandleQueryData

HandleQueryData handles the `QueryData` request for the GitLab datasource

func UnmarshalQuery

func UnmarshalQuery(b []byte, v interface{}) *backend.DataResponse

UnmarshalQuery attempts to unmarshal a query from JSON

Types

type Datasource

type Datasource interface {
	HandleCommitsQuery(context.Context, *models.CommitsQuery, backend.DataQuery) (dfutil.Framer, error)
	CheckHealth(context.Context) error
}

The Datasource type handles the requests sent to the datasource backend.

type Handler

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

Handler is the plugin entrypoint and implements all of the necessary handler functions for dataqueries, healthchecks, and resources.

func (*Handler) CheckHealth

CheckHealth handles health checks sent from Grafana to the plugin. The main use case for these health checks is the test button on the datasource configuration page which allows users to verify that a datasource is working as expected.

func (*Handler) QueryData

QueryData handles multiple queries and returns multiple responses. req contains the queries []DataQuery (where each query contains RefID as a unique identifier). The QueryDataResponse contains a map of RefID to the response for each query, and each response contains Frames ([]*Frame).

func (*Handler) ServeHTTP

func (cr *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the main HTTP handler for serving resource calls.

type Instance

type Instance struct {
	Datasource Datasource
}

Instance is the root Datasource implementation that wraps a Datasource.

func NewGitLabInstance

func NewGitLabInstance(ctx context.Context, settings models.Settings) *Instance

NewGitLabInstance creates a new NewGitLabInstance using the settings to determine if things like the Caching Wrapper should be enabled.

func (*Instance) CheckHealth

func (i *Instance) CheckHealth(ctx context.Context) error

CheckHealth performs a data source health check.

func (*Instance) HandleCommitsQuery

func (i *Instance) HandleCommitsQuery(ctx context.Context, q *models.CommitsQuery, req backend.DataQuery) (dfutil.Framer, error)

HandleCommitsQuery implements the Datasource interface.

type QueryHandlerFunc

type QueryHandlerFunc func(context.Context, backend.DataQuery) backend.DataResponse

QueryHandlerFunc is the function signature used for mux.HandleFunc

type Server

type Server struct {
	Datasource Datasource
}

Server is the main handler for datasource queries. It forwards requests to the embedded datasource interface.

func (*Server) HandleCommits

func (s *Server) HandleCommits(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)

HandleCommits handles the plugin query for GitLab Commits

Jump to

Keyboard shortcuts

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