config

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	Raw() []byte
	Unmarshal(v interface{}) error
	Get(key string) (interface{}, bool)
	GetString(key string) (string, bool)
	GetBool(key string) (bool, bool)
	GetInt(key string) (int64, bool)
	GetFloat(key string) (float64, bool)
	GetDuration(key string) (time.Duration, bool)
	GetTime(key string) (time.Time, bool)
}

Config is config interface

type Data

type Data interface {
	Unmarshal(interface{}) error
	Raw() []byte
}

type Source added in v1.0.0

type Source interface {
	// 如果path是以/结尾,则是目录,否则当作key处理
	Subscribe(path string) Watcher
	Get(ctx context.Context, path string) []Spec
}

Source is config interface

type Spec

type Spec struct {
	Key  string
	Data Data
}

type Watcher

type Watcher interface {
	// Watch 第一次访问的时候如果有值则立马返回spec;后面watch的时候有变更才返回
	// 如果不传key则watch整个文件变动
	// 如果超时或者Watcher被Close应当抛出错误
	Watch(ctx context.Context) ([]Spec, error)
	Close()
}

Watcher is topic watch

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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