Documentation ¶
Index ¶
- type ConfigManager
- func (c *ConfigManager) Create(ctx context.Context, request *configpb.CreateRequest) (*configpb.CreateResponse, error)
- func (c *ConfigManager) CreateConfig(version *configpb.Version, component, componentID, cfg string) (*configpb.Version, string, *configpb.Status)
- func (c *ConfigManager) Delete(ctx context.Context, request *configpb.DeleteRequest) (*configpb.DeleteResponse, error)
- func (c *ConfigManager) DeleteConfig(kind *configpb.ConfigKind, version *configpb.Version) *configpb.Status
- func (c *ConfigManager) Get(ctx context.Context, request *configpb.GetRequest) (*configpb.GetResponse, error)
- func (c *ConfigManager) GetAll(ctx context.Context, request *configpb.GetAllRequest) (*configpb.GetAllResponse, error)
- func (c *ConfigManager) GetAllComponentIDs() map[string][]string
- func (c *ConfigManager) GetAllConfig(ctx context.Context) ([]*configpb.LocalConfig, *configpb.Status)
- func (c *ConfigManager) GetComponent(id string) string
- func (c *ConfigManager) GetComponentIDs(component string) []string
- func (c *ConfigManager) GetConfig(version *configpb.Version, component, componentID string) (*configpb.Version, string, *configpb.Status)
- func (c *ConfigManager) GetGlobalConfigs(component string) *GlobalConfig
- func (c *ConfigManager) GetGlobalVersion(gc *GlobalConfig) uint64
- func (c *ConfigManager) GetLatestVersion(component, componentID string) *configpb.Version
- func (c *ConfigManager) GetLocalConfig(component, componentID string) *LocalConfig
- func (c *ConfigManager) GetLocalVersion(lc *LocalConfig) *configpb.Version
- func (c *ConfigManager) Persist(storage *core.Storage) error
- func (c *ConfigManager) Reload(storage *core.Storage) error
- func (c *ConfigManager) Update(ctx context.Context, request *configpb.UpdateRequest) (*configpb.UpdateResponse, error)
- func (c *ConfigManager) UpdateConfig(kind *configpb.ConfigKind, version *configpb.Version, ...) (*configpb.Version, *configpb.Status)
- func (c *ConfigManager) UpdateGlobal(component string, version *configpb.Version, entries []*configpb.ConfigEntry) (*configpb.Version, *configpb.Status)
- type EntryValue
- type GlobalConfig
- type LocalConfig
- type Server
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 ¶
func (c *ConfigManager) Create(ctx context.Context, request *configpb.CreateRequest) (*configpb.CreateResponse, error)
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 ¶
func (c *ConfigManager) Delete(ctx context.Context, request *configpb.DeleteRequest) (*configpb.DeleteResponse, error)
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 ¶
func (c *ConfigManager) Get(ctx context.Context, request *configpb.GetRequest) (*configpb.GetResponse, error)
Get implements gRPC PDServer.
func (*ConfigManager) GetAll ¶
func (c *ConfigManager) GetAll(ctx context.Context, request *configpb.GetAllRequest) (*configpb.GetAllResponse, error)
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 ¶
func (c *ConfigManager) Update(ctx context.Context, request *configpb.UpdateRequest) (*configpb.UpdateResponse, error)
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 ¶
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.