xconfig

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 12 Imported by: 4

README

配置包

  • 热更新
  • 定时主动拉取

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IConfig

type IConfig interface {
	// ReloadConfig 加载配置 被动通知
	// 从配置源加载到内存
	ReloadConfig() error

	// Scan 将配置扫描到结构体
	Scan(v any)

	// GetString 支持json/yaml通过键名获取值 不支持数组
	GetString(key string) string

	// Subscribe 用户订阅Watch事件
	Subscribe(key string, ch chan struct{})
	// UnSubscribe 用户取消订阅
	UnSubscribe(key string)

	// Close 关闭
	Close()
}

IConfig 配置接口 功能如下: 1.热更新 主动轮询/被动通知 2.通过key获取配置 3.订阅配置变化

func New

func New(ctx context.Context, source Source, opts ...Option) IConfig

New 创建配置类 storeHandler 描述资源以何种形式存储到Config.value 返回需要存储的值

type Option

type Option func(*config)

func WithWatch added in v0.0.4

func WithWatch(interval time.Duration) Option

WithWatch 监控 推荐30秒

type ReloadConfigInterface added in v0.0.3

type ReloadConfigInterface interface {
	// ReloadConfig 实现配置重载功能
	ReloadConfig() error
}

ReloadConfigInterface 重载配置Interface

type Source

type Source interface {
	// GetConfig 获取配置
	GetConfig() ([]byte, error)
}

Source 资源接口

Directories

Path Synopsis
Package apollo @Description TODO @Author jiangyang @Created 2021/9/5 11:36 上午
Package apollo @Description TODO @Author jiangyang @Created 2021/9/5 11:36 上午

Jump to

Keyboard shortcuts

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