Documentation
¶
Index ¶
- func Close()
- func Get(pattern string, def ...any) value.Value
- func Has(pattern string) bool
- func Set(pattern string, value any) error
- func SetConfigurator(configurator Configurator)
- func SetConfiguratorWithSources(sources ...Source)
- func Store(ctx context.Context, source string, file string, content any, override ...bool) error
- func Watch(cb WatchCallbackFunc, names ...string)
- type Configuration
- type Configurator
- type Decoder
- type Encoder
- type Matcher
- type Mode
- type Option
- type Scanner
- type Source
- type WatchCallbackFunc
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetConfiguratorWithSources ¶
func SetConfiguratorWithSources(sources ...Source)
SetConfiguratorWithSources 通过设置配置源来设置配置器
Types ¶
type Configuration ¶
type Configuration struct {
Path string // 文件路径
File string // 文件全称
Name string // 文件名称
Format string // 文件格式
Content []byte // 文件内容
FullPath string // 文件全路径
// contains filtered or unexported fields
}
Configuration 配置项
type Configurator ¶
type Configurator interface {
// Has 检测多个匹配规则中是否存在配置
Has(pattern string) bool
// Get 获取配置值
Get(pattern string, def ...any) value.Value
// Set 设置配置值
Set(pattern string, value any) error
// Match 匹配多个规则
Match(patterns ...string) Matcher
// Watch 设置监听回调
Watch(cb WatchCallbackFunc, names ...string)
// Load 加载配置项
Load(ctx context.Context, source string, file ...string) ([]*Configuration, error)
// Store 保存配置项
Store(ctx context.Context, source string, file string, content any, override ...bool) error
// Close 关闭配置监听
Close()
}
func NewConfigurator ¶
func NewConfigurator(opts ...Option) Configurator
type Matcher ¶
type Source ¶
type Source interface {
// Name 配置源名称
Name() string
// Load 加载配置项
Load(ctx context.Context, file ...string) ([]*Configuration, error)
// Store 保存配置项
Store(ctx context.Context, file string, content []byte) error
// Watch 监听配置项
Watch(ctx context.Context) (Watcher, error)
// Close 关闭配置源
Close() error
}
type WatchCallbackFunc ¶
type WatchCallbackFunc func(names ...string)
type Watcher ¶
type Watcher interface {
// Next 返回配置列表
Next() ([]*Configuration, error)
// Stop 停止监听
Stop() error
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.