xconfig

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 6 Imported by: 4

README

配置包

  • 热更新
  • 定时主动拉取

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

func (*Config) Scan

func (c *Config) Scan(v interface{}) error

func (*Config) Watch

func (c *Config) Watch(handle func(c *Config)) error

Watch 多次watch也只会收到一个通知

type IConfig

type IConfig interface {
	Scan(v interface{}) error
	Watch(func(c *Config)) error
}

IConfig 配置类型的抽象 功能如下: 1.热更新(尚不完善)TODO 2.获取配置

func New

func New(opts ...Option) IConfig

type Option

type Option func(*Config)

func WithContext

func WithContext(ctx context.Context) Option

WithContext 传递上下文

func WithDecoder

func WithDecoder(decoder func([]byte, interface{}) error) Option

WithDecoder 解码器

func WithSource

func WithSource(s Source) Option

WithSource 资源配置

type Source

type Source interface {
	Load() error
	Value() []byte
	Watch() (chan struct{}, error)
	WithContext(ctx context.Context) 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