Chore: Soft failure in plugin initialization (#66210)

This commit is contained in:
Andres Martinez Gotor
2023-04-12 11:34:16 +02:00
committed by GitHub
parent 48de17945f
commit 52f39e6fa0
3 changed files with 125 additions and 12 deletions

View File

@@ -299,23 +299,28 @@ func (m *FakeProcessManager) Stop(ctx context.Context, pluginID string) error {
}
type FakeBackendProcessProvider struct {
Requested map[string]int
Invoked map[string]int
Requested map[string]int
Invoked map[string]int
BackendFactoryFunc func(context.Context, *plugins.Plugin) backendplugin.PluginFactoryFunc
}
func NewFakeBackendProcessProvider() *FakeBackendProcessProvider {
return &FakeBackendProcessProvider{
f := &FakeBackendProcessProvider{
Requested: make(map[string]int),
Invoked: make(map[string]int),
}
f.BackendFactoryFunc = func(ctx context.Context, p *plugins.Plugin) backendplugin.PluginFactoryFunc {
f.Requested[p.ID]++
return func(pluginID string, _ log.Logger, _ []string) (backendplugin.Plugin, error) {
f.Invoked[pluginID]++
return &FakePluginClient{}, nil
}
}
return f
}
func (pr *FakeBackendProcessProvider) BackendFactory(_ context.Context, p *plugins.Plugin) backendplugin.PluginFactoryFunc {
pr.Requested[p.ID]++
return func(pluginID string, _ log.Logger, _ []string) (backendplugin.Plugin, error) {
pr.Invoked[pluginID]++
return &FakePluginClient{}, nil
}
func (pr *FakeBackendProcessProvider) BackendFactory(ctx context.Context, p *plugins.Plugin) backendplugin.PluginFactoryFunc {
return pr.BackendFactoryFunc(ctx, p)
}
type FakeLicensingService struct {