rconfig

package module
v0.0.0-...-9b1b795 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 6 Imported by: 0

README

配置中心(目前是基于etcd)


ctrl c/v永不过时 !!!

本来是想用viper的,毕竟一看官方文档, 我靠,直接支持远程etcd,这tm不香?结果配半天搞不成,各种环境依赖打架,go mod支持太不友好了。 工具嘛,要尽可能的轻量,我尽可能的设计成插件化,即使不用rconfig,用etcd也可直接使用。

├─bytes.go          用于把字节类型序列化成其它类型
├─rconfig.go        代码入口配置
├─rconfig_test.go   代码单元测试
├─watcher.go        接口,只要实现该接口就就可以使用rconfig,为以后对接apollo或者其它配置中心预留。
│    
├─etcd
│    ├─etcd.go      etcd服务
│    ├─etcd_test.go etcd服务单元测试
│    ├─options.go   选项,用于配置etcd路径
│    └─watcher.go   etcd监测变化方法

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rconfig

type Rconfig interface {
	// Get 获取值(每次使用都要重新序列化)
	Get(path string) Val
	// MapValue 获取值(已经序列化好内容)
	MapValue(path, key string) interface{}
	// Map 获取值(已经序列化好内容)
	Map(path string) map[interface{}]interface{}
	// Watch 监听
	Watch()
	// Close 关闭
	Close()
}

func NewRConfig

func NewRConfig(watcher Watcher, way string) (Rconfig, error)

type Val

type Val []byte

func (Val) Bytes

func (h Val) Bytes() []byte

func (Val) FormatJson

func (h Val) FormatJson(v interface{}) error

func (Val) FormatYaml

func (h Val) FormatYaml(v interface{}) error

func (Val) String

func (h Val) String() string

type Watcher

type Watcher interface {
	// Watch 监听
	Watch() <-chan string
	// Get 获取配置
	Get() *sync.Map
	// Close 关闭
	Close()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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