local

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 10 Imported by: 0

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

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

Boot initializes the local config source provider. No additional startup logic required.

Boot 初始化本地配置源 provider。 无需额外启动逻辑。

func (*Provider) DependsOn

func (p *Provider) DependsOn() []string

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

func (p *Provider) IsDefer() bool

IsDefer indicates local config source should defer loading. Allows other providers to register before config source initialization.

IsDefer 表示本地配置源应延迟加载。 允许其他 provider 在配置源初始化之前注册。

func (*Provider) Name

func (p *Provider) Name() string

Name returns provider name for identification.

Name 返回 provider 名称,用于标识。

func (*Provider) Provides

func (p *Provider) Provides() []string

Provides returns the capability keys this provider exposes. Exposes ConfigSourceKey for config source abstraction.

Provides 返回 provider 暴露的能力键。 暴露 ConfigSourceKey 用于配置源抽象。

func (*Provider) Register

func (p *Provider) Register(c runtimecontract.Container) error

Register binds the local config source factory to the container. Core logic: Create Source instance with config, bind to container.

Register 将本地配置源工厂绑定到容器。 核心逻辑:创建 Source 实例并绑定到容器。

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 NewSource

func NewSource(cfg *datacontract.ConfigSourceConfig) *Source

NewSource 创建本地配置源。

func (*Source) Close

func (s *Source) Close() error

Close closes the config source (no cleanup required for local files).

Close 关闭配置源(本地文件无需清理)。

func (*Source) Get

func (s *Source) Get(ctx context.Context, key string) (any, error)

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

func (s *Source) Load(ctx context.Context) (map[string]any, error)

Load loads configuration from local files. Core logic: Reuse LoadLocalConfigToViper, return all settings.

Load 从本地文件加载配置。 核心逻辑:复用 LoadLocalConfigToViper,返回所有配置项。

func (*Source) Set

func (s *Source) Set(ctx context.Context, key string, value any) error

Set sets a single configuration item (not supported for local files). Direct YAML file modification required instead.

Set 设置单个配置项(本地文件不支持)。 需直接修改 YAML 文件。

func (*Source) Watch

Watch watches configuration changes (not supported for local files). Use Reload to update configuration manually.

Watch 监听配置变化(本地文件不支持)。 使用 Reload 手动更新配置。

Jump to

Keyboard shortcuts

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