Documentation
¶
Overview ¶
Package local provides local file config source implementation for gorp framework. Reads config/*.yaml files with layered overlay support (base + env + env directory). Does not support hot update (file changes require manual Reload).
本地文件配置源包,提供 gorp 框架的本地配置源实现。 读取 config/*.yaml 文件,支持分层覆盖(基础 + 环境 + 环境目录)。 不支持热更新(文件变更需要手动 Reload)。
Index ¶
- type Provider
- type Source
- func (s *Source) Close() error
- func (s *Source) Get(ctx context.Context, key string) (any, error)
- func (s *Source) Load(ctx context.Context) (map[string]any, error)
- func (s *Source) Set(ctx context.Context, key string, value any) error
- func (s *Source) Watch(ctx context.Context, key string) (datacontract.ConfigWatcher, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct{}
Provider provides local file config source implementation. Core logic: Bind Source factory, delegate loading to Source.Load.
Provider 提供本地文件配置源实现。 核心逻辑:绑定 Source 工厂、委托加载给 Source.Load。
func NewProvider ¶
func NewProvider() *Provider
NewProvider creates a new local config source provider.
NewProvider 创建新的本地配置源 provider。
func (*Provider) Boot ¶
func (p *Provider) Boot(c runtimecontract.Container) error
Boot initializes the local config source provider. No additional startup logic required.
Boot 初始化本地配置源 provider。 无需额外启动逻辑。
func (*Provider) DependsOn ¶
DependsOn returns the keys this provider depends on. Local config source depends on Root for config path.
DependsOn 返回该 provider 依赖的 key。 Local config source 依赖 Root 获取配置路径。
func (*Provider) IsDefer ¶
IsDefer indicates local config source should defer loading. Allows other providers to register before config source initialization.
IsDefer 表示本地配置源应延迟加载。 允许其他 provider 在配置源初始化之前注册。
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source is the local file config source implementation. Reuses framework/provider/config local config loading chain. Core logic: Delegate to LoadLocalConfigToViper for consistent loading.
Source 是本地文件配置源实现。 复用 framework/provider/config 的本地配置加载主链。 核心逻辑:委托给 LoadLocalConfigToViper 实现一致加载。
func (*Source) Close ¶
Close closes the config source (no cleanup required for local files).
Close 关闭配置源(本地文件无需清理)。
func (*Source) Get ¶
Get retrieves a single configuration item. Local files require full loading before key lookup. Core logic: Load all config, traverse nested keys.
Get 获取单个配置项。 本地文件需要全部加载后才能查询键。 核心逻辑:加载全部配置、遍历嵌套键。
func (*Source) Load ¶
Load loads configuration from local files. Core logic: Reuse LoadLocalConfigToViper, return all settings.
Load 从本地文件加载配置。 核心逻辑:复用 LoadLocalConfigToViper,返回所有配置项。
func (*Source) Set ¶
Set sets a single configuration item (not supported for local files). Direct YAML file modification required instead.
Set 设置单个配置项(本地文件不支持)。 需直接修改 YAML 文件。
func (*Source) Watch ¶
func (s *Source) Watch(ctx context.Context, key string) (datacontract.ConfigWatcher, error)
Watch watches configuration changes (not supported for local files). Use Reload to update configuration manually.
Watch 监听配置变化(本地文件不支持)。 使用 Reload 手动更新配置。