configmanager

package
v4.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: Apache-2.0 Imports: 18 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) GetAll

GetAll implements gRPC PDServer.

func (*ConfigManager) GetAllComponentIDs

func (c *ConfigManager) GetAllComponentIDs() map[string][]string

GetAllComponentIDs returns all components.

func (*ConfigManager) GetAllConfig

func (c *ConfigManager) GetAllConfig(ctx context.Context) ([]*configpb.LocalConfig, *configpb.Status)

GetAllConfig returns all configs in the config manager.

func (*ConfigManager) GetComponent

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

GetComponent returns the component from a given component ID.

func (*ConfigManager) GetComponentIDs

func (c *ConfigManager) GetComponentIDs(component string) []string

GetComponentIDs returns component IDs for a given component.

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) GetGlobalVersion

func (c *ConfigManager) GetGlobalVersion(gc *GlobalConfig) uint64

GetGlobalVersion returns the global version.

func (*ConfigManager) GetLatestVersion

func (c *ConfigManager) GetLatestVersion(component, componentID string) *configpb.Version

GetLatestVersion returns the latest version of config for a given a component ID.

func (*ConfigManager) GetLocalConfig

func (c *ConfigManager) GetLocalConfig(component, componentID string) *LocalConfig

GetLocalConfig returns the local config for a given component and component ID.

func (*ConfigManager) GetLocalVersion

func (c *ConfigManager) GetLocalVersion(lc *LocalConfig) *configpb.Version

GetLocalVersion returns the local version.

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.

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.

type Server

type Server interface {
	IsClosed() bool
	ClusterID() uint64
	GetConfig() *config.Config
	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