plugin

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 13 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 NewDataSourceInstance added in v1.3.0

func NewDataSourceInstance(_ context.Context, settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error)

NewDataSourceInstance creates a new instance

func NewGitHubInstance

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

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

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

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) HandleProjectsQuery added in v1.3.0

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

HandleProjectsQuery is the cache wrapper for the project 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) HandleStargazersQuery added in v1.4.0

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

HandleStargazersQuery is the cache wrapper for the stargazer 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

func (*CachedDatasource) HandleVulnerabilitiesQuery added in v1.3.0

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

HandleVulnerabilitiesQuery is the cache wrapper for the issue query handler

func (*CachedDatasource) HandleWorkflowUsageQuery added in v1.4.7

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

HandleWorkflowUsageQuery is the cache wrapper for the workflows usage query handler

func (*CachedDatasource) HandleWorkflowsQuery added in v1.4.7

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

HandleWorkflowsQuery is the cache wrapper for the workflows query handler

func (*CachedDatasource) QueryData added in v1.3.0

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

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

type Datasource interface {
	HandleRepositoriesQuery(context.Context, *models.RepositoriesQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleIssuesQuery(context.Context, *models.IssuesQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleCommitsQuery(context.Context, *models.CommitsQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleTagsQuery(context.Context, *models.TagsQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleReleasesQuery(context.Context, *models.ReleasesQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleContributorsQuery(context.Context, *models.ContributorsQuery, backend.DataQuery) (dfutil.Framer, error)
	HandlePullRequestsQuery(context.Context, *models.PullRequestsQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleLabelsQuery(context.Context, *models.LabelsQuery, backend.DataQuery) (dfutil.Framer, error)
	HandlePackagesQuery(context.Context, *models.PackagesQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleMilestonesQuery(context.Context, *models.MilestonesQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleVulnerabilitiesQuery(context.Context, *models.VulnerabilityQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleProjectsQuery(context.Context, *models.ProjectsQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleStargazersQuery(context.Context, *models.StargazersQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleWorkflowsQuery(context.Context, *models.WorkflowsQuery, backend.DataQuery) (dfutil.Framer, error)
	HandleWorkflowUsageQuery(context.Context, *models.WorkflowUsageQuery, backend.DataQuery) (dfutil.Framer, error)
	CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
	QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
}

The Datasource type handles the requests sent to the datasource backend

Jump to

Keyboard shortcuts

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