cConfig

package module
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ExplainRegexpText  = `\$text\{([\w_\-]+)(\.?([\w_\-]+))?\}`                        // 字符串替换字符串
	ExplainRegexpJson  = `\"\$json\{([\w_\-]+)(\.?([\w_\-]+))?\}\"`                    // 字符串替换对象
	ExplainRegexpArray = `\"\$(array|jsonArray|slice)\{([\w_\-]+)(\.?([\w_\-]+))?\}\"` // 数组添加元素
)

Variables

View Source
var Component = &ConfigComponent{}

Functions

func Explain added in v0.4.0

func Explain(source string, includes map[string]string) (result string, names map[string][2]string, ok bool)

func GetConf

func GetConf(name string) (any, error)

func ReplaceSlice added in v0.4.0

func ReplaceSlice(s, old, new string) string

Types

type ClientInterface added in v0.4.0

type ClientInterface interface {
	Driver() ConfigCenterDriver
	InitClient() error
	ReadConf(id, group string, explain bool) (string, error)
}

type ConfigCenterConf

type ConfigCenterConf struct {
	Enable   bool                           `json:"enable"`
	Backup   bool                           `json:"backup"`
	Driver   ConfigCenterDriver             `json:"driver"`
	Interval int64                          `json:"interval"`
	Layers   int64                          `json:"layers"`
	Clients  *ConfigCenterConf_Clients      `json:"clients"`
	Listens  []*ConfigCenterConf_ListenItem `json:"listens"`
}

func (*ConfigCenterConf) ConfigName

func (i *ConfigCenterConf) ConfigName() string

type ConfigCenterConf_Clients added in v0.0.9

type ConfigCenterConf_Clients struct {
	File      *FileClient     `json:"file"`
	Nacos     *NacosClient    `json:"nacos"`
	Customize ClientInterface `json:"-"`
}

type ConfigCenterConf_ListenItem added in v0.4.0

type ConfigCenterConf_ListenItem struct {
	Group string `json:"group"`
	Data  string `json:"data"`
	Conf  string `json:"conf"`
}

type ConfigCenterDriver added in v0.4.0

type ConfigCenterDriver string
const (
	ConfigCenterConfigName = "ConfigCenterConf"

	FileDriver      ConfigCenterDriver = "file"
	NacosDriver     ConfigCenterDriver = "nacos"
	CustomizeDriver ConfigCenterDriver = "customize"
)

type ConfigComponent added in v0.3.2

type ConfigComponent struct{}

func (*ConfigComponent) Inject added in v0.3.2

func (i *ConfigComponent) Inject(instance any) bool

func (*ConfigComponent) InjectConf added in v0.4.0

func (i *ConfigComponent) InjectConf(config cComponents.ConfigInterface) bool

func (*ConfigComponent) Listen added in v0.4.0

func (*ConfigComponent) Load added in v0.3.2

func (i *ConfigComponent) Load()

type ConfigContainer

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

func (*ConfigContainer) CompareVersion added in v0.4.0

func (i *ConfigContainer) CompareVersion(name, version string) bool

func (*ConfigContainer) Get added in v0.4.0

func (i *ConfigContainer) Get(name string) any

func (*ConfigContainer) GetConfigListeners added in v0.4.0

func (i *ConfigContainer) GetConfigListeners(name string) []cComponents.ListenHandler

func (*ConfigContainer) Is added in v0.4.0

func (i *ConfigContainer) Is(instance any) bool

func (*ConfigContainer) IsConfigListener added in v0.4.0

func (i *ConfigContainer) IsConfigListener(instance any) bool

func (*ConfigContainer) Range added in v0.4.0

func (i *ConfigContainer) Range(f func(instance any))

func (*ConfigContainer) Remove added in v0.4.0

func (i *ConfigContainer) Remove(name string) bool

func (*ConfigContainer) Save added in v0.4.0

func (i *ConfigContainer) Save(instance any) bool

func (*ConfigContainer) SaveConfigListener added in v0.4.0

func (i *ConfigContainer) SaveConfigListener(listener *cComponents.ConfigListener) bool

func (*ConfigContainer) SaveVersion added in v0.4.0

func (i *ConfigContainer) SaveVersion(name, version string)

type DecoderInterface added in v0.4.2

type DecoderInterface interface {
	Decode(data string) error
}

type FileClient added in v0.0.9

type FileClient struct {
	Namespace string `json:"namespace"`
	Path      string `json:"path"`
}

func (*FileClient) Driver added in v0.4.0

func (i *FileClient) Driver() ConfigCenterDriver

func (*FileClient) InitClient added in v0.0.9

func (i *FileClient) InitClient() error

func (*FileClient) ReadConf added in v0.0.9

func (i *FileClient) ReadConf(id, group string, explain bool) (result string, err error)

type NacosClient added in v0.0.9

type NacosClient struct {
	Scheme    string `json:"scheme"`
	Host      string `json:"host"`
	Port      uint64 `json:"port"`
	Username  string `json:"username"`
	Password  string `json:"password"`
	Namespace string `json:"namespace"`
	Path      string `json:"path"`
	// contains filtered or unexported fields
}

func (*NacosClient) Driver added in v0.4.0

func (i *NacosClient) Driver() ConfigCenterDriver

func (*NacosClient) InitClient added in v0.0.9

func (i *NacosClient) InitClient() error

func (*NacosClient) ReadConf added in v0.0.9

func (i *NacosClient) ReadConf(id, group string, explain bool) (result string, err error)

type ReplaceFunc added in v0.4.0

type ReplaceFunc func(s, old, new string) string

Jump to

Keyboard shortcuts

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