Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrConfigNotFound = errors.New("configuration not found") ErrInvalidConfig = errors.New("invalid configuration") )
Functions ¶
This section is empty.
Types ¶
type ConfigCenter ¶
ConfigCenter defines the interface for configuration center
func NewConfigCenter ¶
func NewConfigCenter(opts *ConfigCenterOptions) (ConfigCenter, error)
NewConfigCenter creates a new configuration center based on the type
type ConfigCenterOptions ¶
type ConfigCenterOptions struct {
Type ConfigCenterType
Address string
Namespace string
Timeout time.Duration
// Consul specific options
Token string
// Nacos specific options
Group string
Username string
Password string
DataID string
Path string
ContentType string
}
ConfigCenterOptions contains options for configuration center
func NewConfigCenterOptions ¶
func NewConfigCenterOptions(t ConfigCenterType, addr string, Path string, contentType string) *ConfigCenterOptions
type ConfigCenterType ¶
type ConfigCenterType string
ConfigCenterType represents the type of configuration center
const ( ConfigCenterTypeConsul ConfigCenterType = "consul" ConfigCenterTypeNacos ConfigCenterType = "nacos" ConfigCenterTypeLocal ConfigCenterType = "local" )
type ConsulConfigCenter ¶
type ConsulConfigCenter struct {
// contains filtered or unexported fields
}
ConsulConfigCenter implements ConfigCenter using Consul
func NewConsulConfigCenter ¶
func NewConsulConfigCenter(opts *ConfigCenterOptions) (*ConsulConfigCenter, error)
NewConsulConfigCenter creates a new Consul configuration center
func (*ConsulConfigCenter) Close ¶
func (c *ConsulConfigCenter) Close() error
Close closes the Consul client connection
func (*ConsulConfigCenter) GetClient ¶
func (c *ConsulConfigCenter) GetClient() *viper.Viper
GetClient returns the underlying viper client
func (*ConsulConfigCenter) GetKey ¶
func (c *ConsulConfigCenter) GetKey(key string) any
GetKey retrieves a configuration value from Consul
type LocalConfigCenter ¶
type LocalConfigCenter struct {
// contains filtered or unexported fields
}
LocalConfigCenter implements ConfigCenter for local testing
func NewLocalConfigCenter ¶
func NewLocalConfigCenter(opts *ConfigCenterOptions) (*LocalConfigCenter, error)
func (*LocalConfigCenter) Close ¶
func (c *LocalConfigCenter) Close() error
func (*LocalConfigCenter) GetClient ¶
func (c *LocalConfigCenter) GetClient() *viper.Viper
func (*LocalConfigCenter) GetKey ¶
func (c *LocalConfigCenter) GetKey(key string) any
Click to show internal directories.
Click to hide internal directories.