confd

package
v0.0.0-...-4c4187b Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONF_KEY_env                = "env"
	CONF_KEY_namespace          = "namespace"
	CONF_KEY_service_redis_port = "service.redis.port"
)

Variables

This section is empty.

Functions

func PaseConfigFile

func PaseConfigFile(confFile string) (string, string, error)

PaseConfigFile 解析文件,得到path,ext

func SubString

func SubString(str string, begin, length int) (substr string)

包含中文的字符串截取

Types

type AppConfig

type AppConfig struct {
	// contains filtered or unexported fields
}

func DefaultAppConfig

func DefaultAppConfig() *AppConfig

func NewAppConfig

func NewAppConfig() *AppConfig

func (*AppConfig) GetAppFlags

func (c *AppConfig) GetAppFlags(deployEnv, namespace, appName, appVersion string,
	confdLocalFile, confdRemoteAddrs, confdRemoteConfigType string, confdSyncMode bool) error

GetAppFlags 从命令行参数与环境变量中获取参数

func (*AppConfig) GetConfdRemoteAddrs

func (c *AppConfig) GetConfdRemoteAddrs() []string

func (*AppConfig) GetLocalConfigFile

func (c *AppConfig) GetLocalConfigFile() string

func (*AppConfig) GetRemoteConfigType

func (c *AppConfig) GetRemoteConfigType() string

func (*AppConfig) GetRootKey

func (c *AppConfig) GetRootKey() string

func (*AppConfig) IsLocal

func (c *AppConfig) IsLocal() bool

func (*AppConfig) IsSync

func (c *AppConfig) IsSync() bool

func (*AppConfig) String

func (c *AppConfig) String() string

type ConfLocalFile

type ConfLocalFile struct {
}

//Config -

func NewConfLocalFile

func NewConfLocalFile() *ConfLocalFile

func (*ConfLocalFile) LoadConfigFromLocalFile

func (cf *ConfLocalFile) LoadConfigFromLocalFile(loadViper *viper.Viper, confFile string) error

func (*ConfLocalFile) ReadConfig

func (cf *ConfLocalFile) ReadConfig(loadViper *viper.Viper, in io.Reader, configType string) error

type Confd

type Confd struct {
	// contains filtered or unexported fields
}

func NewConfd

func NewConfd(appConfig *AppConfig) *Confd

func (*Confd) AllKeys

func (cfd *Confd) AllKeys() []string

func (*Confd) BindConfig

func (cfd *Confd) BindConfig() error

func (*Confd) Get

func (cfd *Confd) Get(key string) interface{}

func (*Confd) GetBool

func (cfd *Confd) GetBool(key string) bool

func (*Confd) GetDuration

func (cfd *Confd) GetDuration(key string) time.Duration

func (*Confd) GetInt

func (cfd *Confd) GetInt(key string) int

func (*Confd) GetRootKey

func (cfd *Confd) GetRootKey() string

func (*Confd) GetString

func (cfd *Confd) GetString(key string) string

func (*Confd) GetStringMap

func (cfd *Confd) GetStringMap(key string) map[string]interface{}

func (*Confd) GetStringMapString

func (cfd *Confd) GetStringMapString(key string) map[string]string

func (*Confd) GetStringMapStringSlice

func (cfd *Confd) GetStringMapStringSlice(key string) map[string][]string

func (*Confd) GetStringSlice

func (cfd *Confd) GetStringSlice(key string) []string

func (*Confd) InConfig

func (cfd *Confd) InConfig(key string) bool

func (*Confd) IsSet

func (cfd *Confd) IsSet(key string) bool

func (*Confd) ReadConfigFileToRemote

func (cfd *Confd) ReadConfigFileToRemote() error

func (*Confd) String

func (cfd *Confd) String() string

func (*Confd) WatchRemoteConfig

func (cfd *Confd) WatchRemoteConfig() error

type EtcdConfd

type EtcdConfd struct {
	// contains filtered or unexported fields
}

EtcdConfd

func NewEtcdConfd

func NewEtcdConfd(appConfig *AppConfig) *EtcdConfd

func (*EtcdConfd) LoadConfigFromRemote

func (ce *EtcdConfd) LoadConfigFromRemote(loadViper *viper.Viper, rootKey, configType string) error

loadConfigFromRemote 依server的rootkey,取出对应的配置文件,并解析更新当前配置

func (*EtcdConfd) ReadConfigFileToETCD

func (ce *EtcdConfd) ReadConfigFileToETCD(confFile, rootKey string) error

func (*EtcdConfd) SyncToEtcd

func (ce *EtcdConfd) SyncToEtcd(addrs, rootkey, confFile string) error

func (*EtcdConfd) WatchRemoteConfig

func (ce *EtcdConfd) WatchRemoteConfig(loadViper *viper.Viper, rootKey, configType string) error

WatchRemoteConfig 监控ETCD,保存配置热更新,不建议在产线使用。产线配置变更建议通过重新发布蓝绿部署等方式,避免产线事故发生

Jump to

Keyboard shortcuts

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