Documentation
¶
Index ¶
- Constants
- func IsExist(path string) bool
- type Adapter
- type AdapterFile
- type Config
- func (c *Config) Available(ctx context.Context, resource ...string) bool
- func (c *Config) Data(ctx context.Context) (map[string]any, error)
- func (c *Config) Get(ctx context.Context, pattern string, def ...any) (*mvar.Var, error)
- func (c *Config) GetAdapter() Adapter
- func (c *Config) SetAdapter(adapter Adapter)
Constants ¶
View Source
const ( // DefaultInstanceName 默认实例名称 DefaultInstanceName = "config" // DefaultConfigFileName 默认配置文件名 DefaultConfigFileName = "config" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter interface { // Get 获取指定键的配置值 Get(ctx context.Context, pattern string) (any, error) // Data 获取所有配置数据 Data(ctx context.Context) (map[string]any, error) // Available 检查和返回配置服务是否可用。 // 可选参数 `resource` 指定某些配置资源。 Available(ctx context.Context, resource ...string) bool }
Adapter 定义配置适配器接口
type AdapterFile ¶
type AdapterFile struct {
// contains filtered or unexported fields
}
func (*AdapterFile) Available ¶
func (c *AdapterFile) Available(ctx context.Context, resource ...string) bool
Available 检查和后端配置服务是否可用。 可选参数 `resource` 指定某些配置资源。
func (*AdapterFile) SetFileName ¶
func (c *AdapterFile) SetFileName(name string)
SetFileName 设置配置文件名
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config 是配置管理对象
func Instance ¶
Instance 返回一个具有默认设置的 Config 实例 参数 `name` 是实例的名称。但需要注意的是,如果配置目录中存在文件 "name.yaml",则将其设置为默认配置文件
注意:如果配置目录中存在文件 "name.yaml",则将其设置为默认配置文件 如果配置目录中不存在文件 "name.yaml",则使用默认配置文件名 "config"
Click to show internal directories.
Click to hide internal directories.