代码拉取完成,页面将自动刷新
// Package config is an interface for dynamic configuration.
package config
import (
"context"
"gitee.com/linxing_3/youye-core/config/loader"
"gitee.com/linxing_3/youye-core/config/reader"
"gitee.com/linxing_3/youye-core/config/source"
"gitee.com/linxing_3/youye-core/config/source/file"
)
// Config is an interface abstraction for dynamic configuration
type Config interface {
// Values provide the reader.Values interface
reader.Values
// Init the config
Init(opts ...Option) error
// Options in the config
Options() Options
// Close Stop the config loader/watcher
Close() error
// Load config sources
Load(source ...source.Source) error
// Sync Force a source changeset sync
Sync() error
// Watch a value for changes
Watch(path ...string) (Watcher, error)
}
// Watcher is the config watcher
type Watcher interface {
Next() (reader.Value, error)
Stop() error
}
// Entity 配置实体
type Entity interface {
OnChange()
}
// Options 配置的参数
type Options struct {
Loader loader.Loader
Reader reader.Reader
Source []source.Source
// for alternative data
Context context.Context
Entity Entity
}
// Option 调用类型
type Option func(o *Options)
var (
// DefaultConfig Default Config Manager
DefaultConfig Config
)
// NewConfig returns new config
func NewConfig(opts ...Option) (Config, error) {
return newConfig(opts...)
}
// Bytes Return config as raw json
func Bytes() []byte {
return DefaultConfig.Bytes()
}
// Map Return config as a map
func Map() map[string]interface{} {
return DefaultConfig.Map()
}
// Scan values to a go type
func Scan(v interface{}) error {
return DefaultConfig.Scan(v)
}
// Sync Force a source changeset sync
func Sync() error {
return DefaultConfig.Sync()
}
// Get a value from the config
func Get(path ...string) reader.Value {
return DefaultConfig.Get(path...)
}
// Load config sources
func Load(source ...source.Source) error {
return DefaultConfig.Load(source...)
}
// Watch a value for changes
func Watch(path ...string) (Watcher, error) {
return DefaultConfig.Watch(path...)
}
// LoadFile is short hand for creating a file source and loading it
func LoadFile(path string) error {
return Load(file.NewSource(
file.WithPath(path),
))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。