mirror of
https://github.com/grafana/grafana.git
synced 2024-12-01 21:19:28 -06:00
c39d6ad97d
* add uninstall flow * add install flow * small cleanup * smaller-footprint solution * cleanup + make bp start auto * fix interface contract * improve naming * accept version arg * ensure use of shared logger * make installer a field * add plugin decommissioning * add basic error checking * fix api docs * making initialization idempotent * add mutex * fix comment * fix test * add test for decommission * improve existing test * add more test coverage * more tests * change test func to use read lock * refactoring + adding test asserts * improve purging old install flow * improve dupe checking * change log name * skip over dupe scanned * make test assertion more flexible * remove trailing line * fix pointer receiver name * update comment * add context to API * add config flag * add base http api test + fix update functionality * simplify existing check * clean up test * refactor tests based on feedback * add single quotes to errs * use gcmp in tests + fix logo issue * make plugin list testing more flexible * address feedback * fix API test * fix linter * undo preallocate * Update docs/sources/administration/configuration.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/administration/configuration.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/administration/configuration.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * fix linting issue in test * add docs placeholder * update install notes * Update docs/sources/plugins/marketplace.md Co-authored-by: Marcus Olsson <marcus.olsson@hey.com> * update access wording * add more placeholder docs * add link to more info * PR feedback - improved errors, refactor, lock fix * improve err details * propagate plugin version errors * don't autostart renderer * add H1 * fix imports Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: Marcus Olsson <marcus.olsson@hey.com>
51 lines
1.9 KiB
Go
51 lines
1.9 KiB
Go
package backendplugin
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
// Manager manages backend plugins.
|
|
type Manager interface {
|
|
//Register registers a backend plugin
|
|
Register(pluginID string, factory PluginFactoryFunc) error
|
|
// RegisterAndStart registers and starts a backend plugin
|
|
RegisterAndStart(ctx context.Context, pluginID string, factory PluginFactoryFunc) error
|
|
// UnregisterAndStop unregisters and stops a backend plugin
|
|
UnregisterAndStop(ctx context.Context, pluginID string) error
|
|
// IsRegistered checks if a plugin is registered with the manager
|
|
IsRegistered(pluginID string) bool
|
|
// StartPlugin starts a non-managed backend plugin
|
|
StartPlugin(ctx context.Context, pluginID string) error
|
|
// CollectMetrics collects metrics from a registered backend plugin.
|
|
CollectMetrics(ctx context.Context, pluginID string) (*backend.CollectMetricsResult, error)
|
|
// CheckHealth checks the health of a registered backend plugin.
|
|
CheckHealth(ctx context.Context, pCtx backend.PluginContext) (*backend.CheckHealthResult, error)
|
|
// CallResource calls a plugin resource.
|
|
CallResource(pluginConfig backend.PluginContext, ctx *models.ReqContext, path string)
|
|
// Get plugin by its ID.
|
|
Get(pluginID string) (Plugin, bool)
|
|
// GetDataPlugin gets a DataPlugin with a certain ID or nil if it doesn't exist.
|
|
// TODO: interface{} is the return type in order to break a dependency cycle. Should be plugins.DataPlugin.
|
|
GetDataPlugin(pluginID string) interface{}
|
|
}
|
|
|
|
// Plugin is the backend plugin interface.
|
|
type Plugin interface {
|
|
PluginID() string
|
|
Logger() log.Logger
|
|
Start(ctx context.Context) error
|
|
Stop(ctx context.Context) error
|
|
IsManaged() bool
|
|
Exited() bool
|
|
Decommission() error
|
|
IsDecommissioned() bool
|
|
backend.CollectMetricsHandler
|
|
backend.CheckHealthHandler
|
|
backend.CallResourceHandler
|
|
backend.StreamHandler
|
|
}
|