Plugins: Add termination stage to plugin loader pipeline (#72822)
* add termination stage * uid -> pluginID (for now) * also fix fakes * add simple test * Fix logger name Co-authored-by: Giuseppe Guerra <giuseppe.guerra@grafana.com> * inline stop func call Co-authored-by: Giuseppe Guerra <giuseppe.guerra@grafana.com> --------- Co-authored-by: Giuseppe Guerra <giuseppe.guerra@grafana.com>
This commit is contained in:
co-authored by
Giuseppe Guerra
parent
7bc6d32eb9
commit
60b4a0b2a4
@@ -1,4 +1,4 @@
|
||||
// Package initialization defines the fourth stage of the plugin loader pipeline.
|
||||
// Package initialization defines the Initialization stage of the plugin loader pipeline.
|
||||
//
|
||||
// The Initialization stage must implement the Initializer interface.
|
||||
// - Initialize(ctx context.Context, ps []*plugins.Plugin) ([]*plugins.Plugin, error)
|
||||
|
||||
@@ -22,8 +22,8 @@ type BackendClientInit struct {
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
// NewBackendClientInitStep returns a new InitializeFunc for registering a backend plugin process.
|
||||
func NewBackendClientInitStep(envVarProvider envvars.Provider,
|
||||
// BackendClientInitStep returns a new InitializeFunc for registering a backend plugin process.
|
||||
func BackendClientInitStep(envVarProvider envvars.Provider,
|
||||
backendProvider plugins.BackendFactoryProvider) InitializeFunc {
|
||||
return newBackendProcessRegistration(envVarProvider, backendProvider).Initialize
|
||||
}
|
||||
@@ -64,8 +64,8 @@ type PluginRegistration struct {
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
// NewPluginRegistrationStep returns a new InitializeFunc for registering a plugin with the plugin registry.
|
||||
func NewPluginRegistrationStep(pluginRegistry registry.Service) InitializeFunc {
|
||||
// PluginRegistrationStep returns a new InitializeFunc for registering a plugin with the plugin registry.
|
||||
func PluginRegistrationStep(pluginRegistry registry.Service) InitializeFunc {
|
||||
return newPluginRegistration(pluginRegistry).Initialize
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestInitializer_Initialize(t *testing.T) {
|
||||
Class: plugins.ClassCore,
|
||||
}
|
||||
|
||||
stepFunc := NewBackendClientInitStep(&fakeEnvVarsProvider{}, &fakeBackendProvider{plugin: p})
|
||||
stepFunc := BackendClientInitStep(&fakeEnvVarsProvider{}, &fakeBackendProvider{plugin: p})
|
||||
|
||||
var err error
|
||||
p, err = stepFunc(context.Background(), p)
|
||||
@@ -52,7 +52,7 @@ func TestInitializer_Initialize(t *testing.T) {
|
||||
Class: plugins.ClassExternal,
|
||||
}
|
||||
|
||||
stepFunc := NewBackendClientInitStep(&fakeEnvVarsProvider{}, &fakeBackendProvider{plugin: p})
|
||||
stepFunc := BackendClientInitStep(&fakeEnvVarsProvider{}, &fakeBackendProvider{plugin: p})
|
||||
|
||||
var err error
|
||||
p, err = stepFunc(context.Background(), p)
|
||||
@@ -76,7 +76,7 @@ func TestInitializer_Initialize(t *testing.T) {
|
||||
Class: plugins.ClassExternal,
|
||||
}
|
||||
|
||||
stepFunc := NewBackendClientInitStep(&fakeEnvVarsProvider{}, &fakeBackendProvider{plugin: p})
|
||||
stepFunc := BackendClientInitStep(&fakeEnvVarsProvider{}, &fakeBackendProvider{plugin: p})
|
||||
|
||||
var err error
|
||||
p, err = stepFunc(context.Background(), p)
|
||||
@@ -94,7 +94,7 @@ func TestInitializer_Initialize(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
i := NewBackendClientInitStep(&fakeEnvVarsProvider{}, &fakeBackendProvider{
|
||||
i := BackendClientInitStep(&fakeEnvVarsProvider{}, &fakeBackendProvider{
|
||||
plugin: p,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user