CeresConfigEtcd

package module
v1.0.4 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(c *Config) CeresConfig.Source

创建一个资源

Types

type Config

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

func DefaultConfig added in v1.0.4

func DefaultConfig() *Config

默认的配置信息

func RawConfig added in v1.0.4

func RawConfig(key string) *Config

RawConfig 返回配置

func ScanConfig added in v1.0.4

func ScanConfig(name string) *Config

ScanConfig 返回配置

func (*Config) Build added in v1.0.4

func (c *Config) Build() CeresConfig.Source

Build 根据配置信息

func (*Config) WithEndpoints added in v1.0.4

func (c *Config) WithEndpoints(addrs ...string) *Config

Addr 连接地址

func (*Config) WithPrefix added in v1.0.4

func (c *Config) WithPrefix(prefix string) *Config

Prefix 前缀

func (*Config) WithStripPrefix added in v1.0.4

func (c *Config) WithStripPrefix(trimPrefix string) *Config

TrimPrefix 去掉前缀前缀

type Marshal

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

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