provider

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadDefaults

func LoadDefaults(k *koanf.Koanf, defaults map[string]interface{}) error

func LoadEnv

func LoadEnv(k *koanf.Koanf, prefix string) error

func LoadFile

func LoadFile(k *koanf.Koanf, path string) error

func MapProvider

func MapProvider(data map[string]interface{}) *rawbytes.RawBytes

Types

type ApolloConfig

type ApolloConfig struct {
	AppID     string
	ConfigKey string
	AccessKey string
	Cluster   string
	ServerURL string
}

ApolloConfig Apollo 配置参数

type ApolloProvider

type ApolloProvider struct {
	// contains filtered or unexported fields
}

ApolloProvider 实现 RemoteProvider 接口,用于从 Apollo 配置中心加载配置

func NewApolloProvider

func NewApolloProvider(cfg ApolloConfig) (*ApolloProvider, error)

NewApolloProvider 创建 Apollo 配置提供者

func (*ApolloProvider) Close

func (p *ApolloProvider) Close() error

Close 关闭 Apollo 客户端

func (*ApolloProvider) Load

func (p *ApolloProvider) Load(ctx context.Context, k *koanf.Koanf) error

Load 从 Apollo 加载配置到 koanf

func (*ApolloProvider) Watch

func (p *ApolloProvider) Watch(ctx context.Context, onChange func(map[string]interface{})) error

Watch 监听 Apollo 配置变更(启动时加载一次,不进行热更新)

type RemoteProvider

type RemoteProvider interface {
	Load(ctx context.Context, k *koanf.Koanf) error
	Watch(ctx context.Context, onChange func(map[string]interface{})) error
}

RemoteProvider 远程配置提供者接口 可以实现 Apollo、Nacos、Consul 等远程配置中心的接入

Jump to

Keyboard shortcuts

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