localregistry

package
v3.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DisableInitialConfiguration  bool   `json:"disable-initial-configuration"`
	InitialConfigurationFilePath string `json:"initial-configuration-file-path"`
}

Config holds the InitFileRegistry configuration.

type InitFileRegistry

type InitFileRegistry struct {
	infra.PluginDeps
	// contains filtered or unexported fields
}

InitFileRegistry is local read-only NB configuration provider with exclusive data source from a file given by a file path (InitConfigFilePath). Its purpose is to seamlessly integrated NB configuration from file as another NB configuration provider (to existing providers: etcd, consul, redis) and integrate it's configuration into agent in the same standard way(datasync.KeyValProtoWatcher). The content of this registry is meant to be only the initial NB configuration for the agent and will not reflect any changes inside given file after initial content loading.

The NB configuration provisioning process and how this registry fits into it:

  1. NB data sources register to default resync plugin (InitFileRegistry registers too in watchNBResync(), but only when there are some NB config data from file, otherwise it makes no sense to register because there is nothing to forward. This also means that before register to resync plugin, the NB config from file will be preloaded)
  2. Call to resync plugin's DoResync triggers resync to NB configuration sources (InitFileRegistry takes its preloaded NB config and stores it into another inner local registry)
  3. NB configuration sources are also watchable (datasync.KeyValProtoWatcher) and the resync data is collected by the watcher.Aggregator (InitFileRegistry is also watchable/forwards data to watcher.Aggregator, it relies on the watcher capabilities of its inner local registry. This is the cause why to preloaded the NB config from file([]proto.Message storage) and push it to another inner local storage later (syncbase.Registry). If we used only one storage (syncbase.Registry for its watch capabilities), we couldn't answer some questins about the storage soon enough (watcher.Aggregator in Watch(...) needs to know whether this storage will send some data or not, otherwise the retrieval can hang on waiting for data that never come))
  4. watcher.Aggregator merges all collected resync data and forwards them its watch clients (it also implements datasync.KeyValProtoWatcher just like the NB data sources).
  5. Clients of Aggregator (currently orchestrator and ifplugin) handle the NB changes/resync properly.

func NewInitFileRegistryPlugin

func NewInitFileRegistryPlugin(opts ...Option) *InitFileRegistry

NewInitFileRegistryPlugin creates a new InitFileRegistry Plugin with the provided Options

func (*InitFileRegistry) Empty

func (r *InitFileRegistry) Empty() bool

Empty checks whether this registry holds data or not. As result of the properties of this registry (readonly, will be filled only once from initial file import), this method directly indicates whether the watchers of this registry will receive any data (Empty() == false, receive initial resync) or won't receive anything at all (Empty() == true)

func (*InitFileRegistry) Init

func (r *InitFileRegistry) Init() error

Init initialize registry

func (*InitFileRegistry) Watch

func (r *InitFileRegistry) Watch(resyncName string, changeChan chan datasync.ChangeEvent,
	resyncChan chan datasync.ResyncEvent, keyPrefixes ...string) (datasync.WatchRegistration, error)

Watch functionality is forwarded to inner syncbase.Registry. For some watchers might be relevant whether any data will be pushed to them at all (i.e. watcher.Aggregator). They should use the Empty() method to find out whether there are (=ever will be do to nature of this registry) any data for pushing to watchers.

type Option

type Option func(*InitFileRegistry)

Jump to

Keyboard shortcuts

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