configmanager

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigManager

type ConfigManager struct {
	sync.RWMutex

	// component -> GlobalConfig
	GlobalCfgs map[string]*GlobalConfig
	// component -> componentID -> LocalConfig
	LocalCfgs map[string]map[string]*LocalConfig
	// contains filtered or unexported fields
}

ConfigManager is used to manage all components' config.

func NewConfigManager

func NewConfigManager(svr Server) *ConfigManager

NewConfigManager creates a new ConfigManager.

func (*ConfigManager) Create

Create implements gRPC PDServer.

func (*ConfigManager) CreateConfig

func (c *ConfigManager) CreateConfig(version *configpb.Version, component, componentID, cfg string) (*configpb.Version, string, *configpb.Status)

CreateConfig is used for registering a component to PD.

func (*ConfigManager) Delete

Delete implements gRPC PDServer.

func (*ConfigManager) DeleteConfig

func (c *ConfigManager) DeleteConfig(kind *configpb.ConfigKind, version *configpb.Version) *configpb.Status

DeleteConfig removes a component from the config manager.

func (*ConfigManager) Get

Get implements gRPC PDServer.

func (*ConfigManager) GetComponent

func (c *ConfigManager) GetComponent(id string) string

GetComponent returns the component from a given component ID.

func (*ConfigManager) GetConfig

func (c *ConfigManager) GetConfig(version *configpb.Version, component, componentID string) (*configpb.Version, string, *configpb.Status)

GetConfig returns config and the latest version.

func (*ConfigManager) GetGlobalConfigs

func (c *ConfigManager) GetGlobalConfigs(component string) *GlobalConfig

GetGlobalConfigs returns the global config for a given component.

func (*ConfigManager) Persist

func (c *ConfigManager) Persist(storage *core.Storage) error

Persist saves the configuration to the storage.

func (*ConfigManager) Reload

func (c *ConfigManager) Reload(storage *core.Storage) error

Reload reloads the configuration from the storage.

func (*ConfigManager) Update

Update implements gRPC PDServer.

func (*ConfigManager) UpdateConfig

func (c *ConfigManager) UpdateConfig(kind *configpb.ConfigKind, version *configpb.Version, entries []*configpb.ConfigEntry) (*configpb.Version, *configpb.Status)

UpdateConfig is used to update a config with a given config type.

func (*ConfigManager) UpdateGlobal

func (c *ConfigManager) UpdateGlobal(component string, version *configpb.Version, entries []*configpb.ConfigEntry) (*configpb.Version, *configpb.Status)

UpdateGlobal is used to update the global config.

type EntryValue

type EntryValue struct {
	Version *configpb.Version
	Value   string
}

EntryValue is composed by version and value.

func NewEntryValue

func NewEntryValue(e *configpb.ConfigEntry, version *configpb.Version) *EntryValue

NewEntryValue creates a new EntryValue.

type GlobalConfig

type GlobalConfig struct {
	Version       uint64
	UpdateEntries map[string]*EntryValue
}

GlobalConfig is used to manage the global config of components.

func NewGlobalConfig

func NewGlobalConfig(entries []*configpb.ConfigEntry, version *configpb.Version) *GlobalConfig

NewGlobalConfig create a new GlobalConfig.

func (*GlobalConfig) GetConfigEntries

func (gc *GlobalConfig) GetConfigEntries() []*configpb.ConfigEntry

GetConfigEntries returns config entries.

func (*GlobalConfig) GetVersion

func (gc *GlobalConfig) GetVersion() uint64

GetVersion returns the global version.

type LocalConfig

type LocalConfig struct {
	Version       *configpb.Version
	UpdateEntries map[string]*EntryValue
	Configs       map[string]interface{}
}

LocalConfig is used to manage the local config of a component.

func NewLocalConfig

func NewLocalConfig(cfg string, version *configpb.Version) (*LocalConfig, error)

NewLocalConfig create a new LocalConfig.

func (*LocalConfig) GetVersion

func (lc *LocalConfig) GetVersion() *configpb.Version

GetVersion return the local config version for a component.

type Server

type Server interface {
	IsClosed() bool
	ClusterID() uint64
	GetRaftCluster() *cluster.RaftCluster
	GetStorage() *core.Storage
	GetMember() *member.Member
}

Server is the interface for configuration manager.

Jump to

Keyboard shortcuts

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