CeresConfigEtcd

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

ceres-config-etcd

「仅发布」配置组件etcd资源适配

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Marshals = map[string]Marshal{
		"json": json.Marshal,
		"xml":  xml.Marshal,
		"yaml": yaml.Marshal,
		"yml":  yaml.Marshal,
		"toml": func(v interface{}) ([]byte, error) {
			b := bytes.NewBuffer(nil)
			defer b.Reset()
			err := toml.NewEncoder(b).Encode(v)
			if err != nil {
				return nil, err
			}
			return b.Bytes(), nil
		},
	}
	Unmarshals = map[string]Unmarshal{
		"json": json.Unmarshal,
		"xml":  xml.Unmarshal,
		"yaml": yaml.Unmarshal,
		"yml":  yaml.Unmarshal,
		"toml": toml.Unmarshal,
	}
)
View Source
var DefaultPrefix = "/ceres/config/"

Functions

func NewSource

func NewSource(opts ...Option) CeresConfig.Source

创建一个资源

Types

type Config

type Config struct {
	*clientv3.Config
	Prefix     string // etcd配置路径
	TrimPrefix string // 删除掉的头部字符串
	Encoding   string // 加解密
	Ctx        context.Context
}

type Marshal

type Marshal func(v interface{}) ([]byte, error)

type Option

type Option func(o *Config)

初始化参数

func Addr

func Addr(addrs ...string) Option

Addr 连接地址

func Prefix

func Prefix(prefix string) Option

Prefix 前缀

func StripPrefix

func StripPrefix(stripPrefix string) Option

StripPrefix 前缀

type Unmarshal

type Unmarshal func(data []byte, v interface{}) error

Jump to

Keyboard shortcuts

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