operationexecutor

package
v1.16.12-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Overview

Package operationexecutor implements interfaces that enable execution of register and unregister operations with a goroutinemap so that more than one operation is never triggered on the same plugin.

Package operationexecutor implements interfaces that enable execution of register and unregister operations with a goroutinemap so that more than one operation is never triggered on the same plugin.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActualStateOfWorldUpdater

type ActualStateOfWorldUpdater interface {
	// AddPlugin add the given plugin in the cache if no existing plugin
	// in the cache has the same socket path.
	// An error will be returned if socketPath is empty.
	AddPlugin(pluginInfo cache.PluginInfo) error

	// RemovePlugin deletes the plugin with the given socket path from the actual
	// state of world.
	// If a plugin does not exist with the given socket path, this is a no-op.
	RemovePlugin(socketPath string)
}

ActualStateOfWorldUpdater defines a set of operations updating the actual state of the world cache after successful registeration/deregistration.

type OperationExecutor

type OperationExecutor interface {
	// RegisterPlugin registers the given plugin using the a handler in the plugin handler map.
	// It then updates the actual state of the world to reflect that.
	RegisterPlugin(socketPath string, foundInDeprecatedDir bool, timestamp time.Time, pluginHandlers map[string]cache.PluginHandler, actualStateOfWorld ActualStateOfWorldUpdater) error

	// UnregisterPlugin deregisters the given plugin using a handler in the given plugin handler map.
	// It then updates the actual state of the world to reflect that.
	UnregisterPlugin(socketPath string, pluginHandlers map[string]cache.PluginHandler, actualStateOfWorld ActualStateOfWorldUpdater) error
}

OperationExecutor defines a set of operations for registering and unregistering a plugin that are executed with a NewGoRoutineMap which prevents more than one operation from being triggered on the same socket path.

These operations should be idempotent (for example, RegisterPlugin should still succeed if the plugin is already registered, etc.). However, they depend on the plugin handlers (for each plugin type) to implement this behavior.

Once an operation completes successfully, the actualStateOfWorld is updated to indicate the plugin is registered/unregistered.

Once the operation is started, since it is executed asynchronously, errors are simply logged and the goroutine is terminated without updating actualStateOfWorld.

func NewOperationExecutor

func NewOperationExecutor(
	operationGenerator OperationGenerator) OperationExecutor

NewOperationExecutor returns a new instance of OperationExecutor.

type OperationGenerator

type OperationGenerator interface {
	// Generates the RegisterPlugin function needed to perform the registration of a plugin
	GenerateRegisterPluginFunc(
		socketPath string,
		foundInDeprecatedDir bool,
		timestamp time.Time,
		pluginHandlers map[string]cache.PluginHandler,
		actualStateOfWorldUpdater ActualStateOfWorldUpdater) func() error

	// Generates the UnregisterPlugin function needed to perform the unregistration of a plugin
	GenerateUnregisterPluginFunc(
		socketPath string,
		pluginHandlers map[string]cache.PluginHandler,
		actualStateOfWorldUpdater ActualStateOfWorldUpdater) func() error
}

OperationGenerator interface that extracts out the functions from operation_executor to make it dependency injectable

func NewOperationGenerator

func NewOperationGenerator(recorder record.EventRecorder) OperationGenerator

NewOperationGenerator is returns instance of operationGenerator

Jump to

Keyboard shortcuts

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