Documentation ¶
Overview ¶
dynamicplugins is a package that manages dynamic plugins in Nomad. It exposes a registry that allows for plugins to be registered/deregistered and also allows subscribers to receive real time updates of these events.
Index ¶
Constants ¶
const ( PluginTypeCSIController = "csi-controller" PluginTypeCSINode = "csi-node" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventType ¶
type EventType string
EventType is the enum of events that will be emitted by a Registry's PluginsUpdatedCh.
type PluginConnectionInfo ¶
type PluginConnectionInfo struct { // SocketPath is the path to the plugins api socket. SocketPath string }
PluginConnectionInfo is the data required to connect to the plugin. note: We currently only support Unix Domain Sockets, but this may be expanded
to support other connection modes in the future.
type PluginDispenser ¶
type PluginDispenser func(info *PluginInfo) (interface{}, error)
type PluginInfo ¶
type PluginInfo struct { Name string Type string Version string // ConnectionInfo should only be used externally during `RegisterPlugin` and // may not be exposed in the future. ConnectionInfo *PluginConnectionInfo // AllocID tracks the allocation running the plugin AllocID string // Options is used for plugin registrations to pass further metadata along to // other subsystems Options map[string]string }
PluginInfo is the metadata that is stored by the registry for a given plugin.
type PluginUpdateEvent ¶
type PluginUpdateEvent struct { EventType EventType Info *PluginInfo }
PluginUpdateEvent is a struct that is sent over a PluginsUpdatedCh when plugins are added or removed from the registry.
type Registry ¶
type Registry interface { RegisterPlugin(info *PluginInfo) error DeregisterPlugin(ptype, name, allocID string) error ListPlugins(ptype string) []*PluginInfo DispensePlugin(ptype, name string) (interface{}, error) PluginForAlloc(ptype, name, allocID string) (*PluginInfo, error) PluginsUpdatedCh(ctx context.Context, ptype string) <-chan *PluginUpdateEvent Shutdown() StubDispenserForType(ptype string, dispenser PluginDispenser) }
Registry is an interface that allows for the dynamic registration of plugins that are running as Nomad Tasks.
func NewRegistry ¶
func NewRegistry(state StateStorage, dispensers map[string]PluginDispenser) Registry
NewRegistry takes a map of `plugintype` to PluginDispenser functions that should be used to vend clients for plugins to be used.
type RegistryState ¶
RegistryState is what we persist in the client state store. It contains a map of plugin types to maps of plugin name -> list of *PluginInfo, sorted by recency of registration
type StateStorage ¶
type StateStorage interface { // GetDynamicPluginRegistryState is used to restore the registry state GetDynamicPluginRegistryState() (*RegistryState, error) // PutDynamicPluginRegistryState is used to store the registry state PutDynamicPluginRegistryState(state *RegistryState) error }
StateStorage is used to persist the dynamic plugin registry's state across agent restarts.