plugin

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const CacheCleanupInterval = time.Minute * 10

CacheCleanupInterval is the interval at which the internal cache is cleaned / garbage collected

View Source
const CacheDuration = time.Minute * 5

CacheDuration is a constant that defines how long to keep cached elements before they are refreshed

Variables

View Source
var ErrNoValue = errors.New("no cached value was found with that key")

ErrNoValue is returned when a cached value is not available in the local cache

Functions

func CheckHealth

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

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 GetRouter

func GetRouter(h Handlers) *mux.Router

GetRouter creates the gorilla/mux router for the HTTP handlers

func HandleQueryData

HandleQueryData handles the `QueryData` request for the Github datasource

func UnmarshalQuery

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

UnmarshalQuery attempts to unmarshal a query from JSON

Types

type CachedDatasource

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

The CachedDatasource wraps the Datasource type and stores an internal map, and responds to queries with cached data. If there is no cached data to respond with, the CachedDatasource forwards the request to the Datasource

func WithCaching

func WithCaching(datasource Datasource) *CachedDatasource

WithCaching accepts a Client and returns a CachedClient which wraps the provided Client

func (*CachedDatasource) CheckHealth

func (c *CachedDatasource) CheckHealth(ctx context.Context) error

CheckHealth forwards the request to the datasource and does not perform any caching

func (*CachedDatasource) Cleanup

func (c *CachedDatasource) Cleanup()

Cleanup removes old cache keys

func (*CachedDatasource) HandleCommitsQuery

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

HandleCommitsQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandleContributorsQuery

func (c *CachedDatasource) HandleContributorsQuery(ctx context.Context, q *models.ContributorsQuery, req backend.DataQuery) (dfutil.Framer, error)

HandleContributorsQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandleIssuesQuery

func (c *CachedDatasource) HandleIssuesQuery(ctx context.Context, q *models.IssuesQuery, req backend.DataQuery) (dfutil.Framer, error)

HandleIssuesQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandleLabelsQuery

func (c *CachedDatasource) HandleLabelsQuery(ctx context.Context, q *models.LabelsQuery, req backend.DataQuery) (dfutil.Framer, error)

HandleLabelsQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandleMilestonesQuery

func (c *CachedDatasource) HandleMilestonesQuery(ctx context.Context, q *models.MilestonesQuery, req backend.DataQuery) (dfutil.Framer, error)

HandleMilestonesQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandlePackagesQuery

func (c *CachedDatasource) HandlePackagesQuery(ctx context.Context, q *models.PackagesQuery, req backend.DataQuery) (dfutil.Framer, error)

HandlePackagesQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandlePullRequestsQuery

func (c *CachedDatasource) HandlePullRequestsQuery(ctx context.Context, q *models.PullRequestsQuery, req backend.DataQuery) (dfutil.Framer, error)

HandlePullRequestsQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandleReleasesQuery

func (c *CachedDatasource) HandleReleasesQuery(ctx context.Context, q *models.ReleasesQuery, req backend.DataQuery) (dfutil.Framer, error)

HandleReleasesQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandleRepositoriesQuery added in v1.0.1

func (c *CachedDatasource) HandleRepositoriesQuery(ctx context.Context, q *models.RepositoriesQuery, req backend.DataQuery) (dfutil.Framer, error)

HandleRepositoriesQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandleTagsQuery

func (c *CachedDatasource) HandleTagsQuery(ctx context.Context, q *models.TagsQuery, req backend.DataQuery) (dfutil.Framer, error)

HandleTagsQuery is the cache wrapper for the issue query handler

type CachedResult

type CachedResult struct {
	Result    dfutil.Framer
	ExpiresAt time.Time
}

CachedResult is a value and a timestamp that defines when the cached value is no longer usable

type Datasource

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 identifer). 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 Handlers

type Handlers struct {
	Labels     http.HandlerFunc
	Milestones http.HandlerFunc
}

Handlers stores the list of http.HandlerFunc functions for the different resource calls

type Instance

type Instance struct {
	Datasource Datasource
	Handlers   Handlers
}

Instance is the root Datasource implementation that wraps a Datasource

func NewGitHubInstance

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

NewGitHubInstance creates a new GitHubInstance 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 ...

func (*Instance) HandleCommitsQuery

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

HandleCommitsQuery ...

func (*Instance) HandleContributorsQuery

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

HandleContributorsQuery ...

func (*Instance) HandleIssuesQuery

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

HandleIssuesQuery ...

func (*Instance) HandleLabelsQuery

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

HandleLabelsQuery ...

func (*Instance) HandleMilestonesQuery

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

HandleMilestonesQuery ...

func (*Instance) HandlePackagesQuery

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

HandlePackagesQuery ...

func (*Instance) HandlePullRequestsQuery

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

HandlePullRequestsQuery ...

func (*Instance) HandleReleasesQuery

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

HandleReleasesQuery ...

func (*Instance) HandleRepositoriesQuery added in v1.0.1

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

HandleRepositoriesQuery ...

func (*Instance) HandleTagsQuery

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

HandleTagsQuery ...

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 github Commits

func (*Server) HandleContributors

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

HandleContributors handles the plugin query for github Contributors

func (*Server) HandleIssues

HandleIssues handles the plugin query for github Issues

func (*Server) HandleLabels

HandleLabels handles the plugin query for github Labels

func (*Server) HandleMilestones

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

HandleMilestones handles the plugin query for github Milestones

func (*Server) HandlePackages

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

HandlePackages handles the plugin query for github Packages

func (*Server) HandlePullRequests

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

HandlePullRequests handles the plugin query for github PullRequests

func (*Server) HandleReleases

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

HandleReleases handles the plugin query for github Releases

func (*Server) HandleRepositories added in v1.0.1

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

HandleRepositories handles the plugin query for github tags

func (*Server) HandleTags

HandleTags handles the plugin query for github tags

Jump to

Keyboard shortcuts

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