etcdlib

package
v0.0.0-...-ce54790 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROLE_LEADER   = "leader"
	ROLE_FOLLOWER = "follower"

	STATUS_HEALTHY   = "healthy"
	STATUS_UNHEALTHY = "unhealthy"
)
View Source
const (
	DEFAULT_DIR_VALUE = "etcdv3_dir_$2H#%gRe3*t"
)
View Source
const WATCH_EVENT_DELETE = "DELETE"

Variables

View Source
var (
	ErrorInvalidRootKey = errors.New("root key should not be empty or end with /")
	ErrorInvalidKey     = errors.New("key should start with /")
	ErrorPutKey         = errors.New("key is not under a directory or key is a directory or key is not empty")
	ErrorKeyNotFound    = errors.New("key has not been set")
	ErrorListKey        = errors.New("can only list a directory")
)

Functions

func Backup

func Backup(fpath string)

func Create

func Create(key, value string) error

func CreateContext

func CreateContext(ctx context.Context, key, value string) error

func CreateDir

func CreateDir(key string) error

func CreateDirContext

func CreateDirContext(ctx context.Context, key string) error

func Delete

func Delete(key string) error

func DeleteContext

func DeleteContext(ctx context.Context, key string) error

func EnsureKey

func EnsureKey(key string) (string, string, error)

func MembersHandler

func MembersHandler() (interface{}, error)

func Put

func Put(key, value string) error

func PutContext

func PutContext(ctx context.Context, key, value string) error

func SetEtcd

func SetEtcd(ctx context.Context, endpoint []string, Prefix string, tls *tls.Config)

func Watch

func Watch(fn func(key, reallyKey, value []byte, revision int64, t string) error)

Types

type Clienter

type Clienter interface {
	Get(key string) (*Node, error)
	GetContext(ctx context.Context, key string) (*Node, error)

	List(key string) ([]*Node, error)
	ListContext(ctx context.Context, key string) ([]*Node, error)

	Put(key, value string) error
	PutContext(ctx context.Context, key, value string) error

	Create(key, value string) error
	CreateContext(ctx context.Context, key, value string) error

	CreateDir(key string) error
	CreateDirContext(ctx context.Context, key string) error

	Delete(key string) error
	DeleteContext(ctx context.Context, key string) error

	MembersHandler() (interface{}, error)

	Watch(fn func(key, reallyKey, value []byte, revision int64, t string) error)

	EnsureKey(key string) (string, string, error)

	Backup(filepath string)

	Close()
}
var EtcdClient Clienter

func New

func New(ctx context.Context, endpoint []string, Prefix string, tls *tls.Config) (Clienter, error)

type Member

type Member struct {
	*etcdserverpb.Member
	Role   string `json:"role"`
	Status string `json:"status"`
	DbSize int64  `json:"db_size"`
}

type Node

type Node struct {
	*mvccpb.KeyValue
	IsDir bool `json:"is_dir"`
}

func Get

func Get(key string) (*Node, error)

func GetContext

func GetContext(ctx context.Context, key string) (*Node, error)

func List

func List(key string) ([]*Node, error)

func ListContext

func ListContext(ctx context.Context, key string) ([]*Node, error)

Jump to

Keyboard shortcuts

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