dconf

package
v0.0.0-...-693abe4 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

each caller should provide 1. etcd addr, prefix 2. same constructor to unmarshal data from etcd

each caller should provide 1. etcd addr, prefix 2. same constructor to unmarshal data from etcd

Index

Constants

View Source
const (
	ErrorKeyNotFound = 100
)

ErrorCode

Variables

This section is empty.

Functions

func IsKeyNotFound

func IsKeyNotFound(err error) bool

IsKeyNotFound check the error

Types

type DConf

type DConf interface {
	Get(key string) (string, error)
	Set(key, value string, preExist ...bool) error
	Del(key string) error
	Keys(prefix string) []string
	Data(prefix string) map[string]string
}

DConf 接口

type DConf3

type DConf3 struct {
	// contains filtered or unexported fields
}

DConf3 synchronizes etcd with in-memory data structures

func NewV3

func NewV3(ctx context.Context, addrs []string, prefix string) (*DConf3, error)

NewV3 inits a DConf3 instance and reads data from etcd

func (*DConf3) Data

func (conf *DConf3) Data(prefix string) map[string]string

Data loads all keys from data

func (*DConf3) Del

func (conf *DConf3) Del(key string) error

Del deletes an entry in etcd

func (*DConf3) Get

func (conf *DConf3) Get(key string) (string, error)

Get gets an entry from memory

func (*DConf3) Keys

func (conf *DConf3) Keys(prefix string) []string

Keys loads all keys from data

func (*DConf3) Set

func (conf *DConf3) Set(key string, value string, preExist ...bool) error

Set stores an entry into etcd

type DConfv2

type DConfv2 struct {
	// contains filtered or unexported fields
}

DConfv2 synchronizes etcd with in-memory data structures

func New

func New(ctx context.Context, addrs []string, prefix string) (*DConfv2, error)

New inits a DConfv2 instance and reads data from etcd

func (*DConfv2) Data

func (conf *DConfv2) Data(prefix string) map[string]string

Data loads all keys from data

func (*DConfv2) Del

func (conf *DConfv2) Del(key string) error

Del deletes an entry in etcd

func (*DConfv2) Get

func (conf *DConfv2) Get(key string) (string, error)

Get gets an entry from memory

func (*DConfv2) Keys

func (conf *DConfv2) Keys(prefix string) []string

Keys loads all keys from data

func (*DConfv2) Set

func (conf *DConfv2) Set(key string, value string, preExist ...bool) error

Set stores an entry into etcd

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents the error returned to client side

func (Error) Error

func (e Error) Error() string

Jump to

Keyboard shortcuts

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