mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 11:02:12 +08:00
Plugins: Remove registry dependency from process manager (#73241)
simplify
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
||||
"path"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
|
||||
@ -62,6 +63,8 @@ type Plugin struct {
|
||||
client backendplugin.Plugin
|
||||
log log.Logger
|
||||
|
||||
mu sync.Mutex
|
||||
|
||||
// This will be moved to plugin.json when we have general support in gcom
|
||||
Alias string `json:"alias,omitempty"`
|
||||
}
|
||||
@ -264,16 +267,24 @@ func (p *Plugin) SetLogger(l log.Logger) {
|
||||
}
|
||||
|
||||
func (p *Plugin) Start(ctx context.Context) error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
|
||||
if p.client == nil {
|
||||
return fmt.Errorf("could not start plugin %s as no plugin client exists", p.ID)
|
||||
}
|
||||
|
||||
return p.client.Start(ctx)
|
||||
}
|
||||
|
||||
func (p *Plugin) Stop(ctx context.Context) error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
|
||||
if p.client == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return p.client.Stop(ctx)
|
||||
}
|
||||
|
||||
@ -285,6 +296,9 @@ func (p *Plugin) IsManaged() bool {
|
||||
}
|
||||
|
||||
func (p *Plugin) Decommission() error {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
|
||||
if p.client != nil {
|
||||
return p.client.Decommission()
|
||||
}
|
||||
|
Reference in New Issue
Block a user