etcd

package
v0.0.0-...-04e6e7a Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

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) config.Source

NewSource 创建一个资源

Types

type Config

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

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig 默认的配置信息

func RawConfig

func RawConfig(key string) *Config

RawConfig 返回配置

func ScanConfig

func ScanConfig(name string) *Config

ScanConfig 返回配置

func (*Config) Build

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

Build 根据配置信息

func (*Config) WithEndpoints

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

WithEndpoints 连接地址

func (*Config) WithPrefix

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

WithPrefix 前缀

func (*Config) WithStripPrefix

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

WithStripPrefix 去掉前缀前缀

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