123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- package operationexecutor
- import (
- "time"
- "k8s.io/kubernetes/pkg/kubelet/pluginmanager/cache"
- "k8s.io/kubernetes/pkg/util/goroutinemap"
- )
- type OperationExecutor interface {
-
-
- RegisterPlugin(socketPath string, timestamp time.Time, pluginHandlers map[string]cache.PluginHandler, actualStateOfWorld ActualStateOfWorldUpdater) error
-
-
- UnregisterPlugin(socketPath string, pluginHandlers map[string]cache.PluginHandler, actualStateOfWorld ActualStateOfWorldUpdater) error
- }
- func NewOperationExecutor(
- operationGenerator OperationGenerator) OperationExecutor {
- return &operationExecutor{
- pendingOperations: goroutinemap.NewGoRoutineMap(true ),
- operationGenerator: operationGenerator,
- }
- }
- type ActualStateOfWorldUpdater interface {
-
-
-
- AddPlugin(pluginInfo cache.PluginInfo) error
-
-
-
- RemovePlugin(socketPath string)
- }
- type operationExecutor struct {
-
-
- pendingOperations goroutinemap.GoRoutineMap
-
-
- operationGenerator OperationGenerator
- }
- var _ OperationExecutor = &operationExecutor{}
- func (oe *operationExecutor) IsOperationPending(socketPath string) bool {
- return oe.pendingOperations.IsOperationPending(socketPath)
- }
- func (oe *operationExecutor) RegisterPlugin(
- socketPath string,
- timestamp time.Time,
- pluginHandlers map[string]cache.PluginHandler,
- actualStateOfWorld ActualStateOfWorldUpdater) error {
- generatedOperation :=
- oe.operationGenerator.GenerateRegisterPluginFunc(socketPath, timestamp, pluginHandlers, actualStateOfWorld)
- return oe.pendingOperations.Run(
- socketPath, generatedOperation)
- }
- func (oe *operationExecutor) UnregisterPlugin(
- socketPath string,
- pluginHandlers map[string]cache.PluginHandler,
- actualStateOfWorld ActualStateOfWorldUpdater) error {
- generatedOperation :=
- oe.operationGenerator.GenerateUnregisterPluginFunc(socketPath, pluginHandlers, actualStateOfWorld)
- return oe.pendingOperations.Run(
- socketPath, generatedOperation)
- }
|