cConfig

package module
v0.4.15 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

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

Variables

View Source
var Component = &ConfigComponent{}

Functions

func GetConf

func GetConf(name string) (any, error)

func ReadEnv added in v0.4.13

func ReadEnv(id, group string, explain bool) (result string, err 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"`
	Zip       *ZipClient      `json:"zip"`
	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"`
	Driver ConfigCenterDriver `json:"driver"`
}

type ConfigCenterDriver added in v0.4.0

type ConfigCenterDriver string
const (
	ConfigCenterConfigName = "ConfigCenterConf"

	FileDriver      ConfigCenterDriver = "file"
	ZipDriver       ConfigCenterDriver = "zip"
	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 ExplainItem added in v0.4.13

type ExplainItem struct {
	Reg         string      `json:"reg"`
	Source      string      `json:"source"`
	Target      string      `json:"target"`
	DataID      string      `json:"data_id"`
	GroupID     string      `json:"group_id"`
	ReplaceFunc ReplaceFunc `json:"-"`
	ReadFunc    ReadFunc    `json:"-"`
}

func Explain added in v0.4.0

func Explain(client ClientInterface, content string) (result []*ExplainItem, err 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 ReadFunc added in v0.4.13

type ReadFunc func(id, group string, explain bool) (result string, err error)

type ReplaceFunc added in v0.4.0

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

type ZipClient added in v0.4.5

type ZipClient struct {
	Namespace string `json:"namespace"`
	Path      string `json:"path"`
	Password  string `json:"password"`
}

func (*ZipClient) Driver added in v0.4.5

func (i *ZipClient) Driver() ConfigCenterDriver

func (*ZipClient) InitClient added in v0.4.5

func (i *ZipClient) InitClient() error

func (*ZipClient) ReadConf added in v0.4.5

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

func (*ZipClient) ReadFile added in v0.4.5

func (i *ZipClient) ReadFile(filename string) ([]byte, error)

Jump to

Keyboard shortcuts

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