etcdutils

package
v0.0.0-...-e46cadb Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(addrs ...string) (client.KeysAPI, error)

Connect to etcd

func Decode

func Decode(s string, v interface{}) error

Decode ...

func Encode

func Encode(v interface{}) (string, error)

Encode ...

Types

type EtcdStore

type EtcdStore struct {
	Kapi client.KeysAPI
	// contains filtered or unexported fields
}

EtcdStore a Store providing enough operation to manage data

func NewEtcdStore

func NewEtcdStore(addrs []string) (*EtcdStore, error)

NewEtcdStore generate a EctdStore

func (*EtcdStore) Delete

func (s *EtcdStore) Delete(k string, recursive bool) error

Delete func to implement the Store interface Delete method

func (*EtcdStore) Existed

func (s *EtcdStore) Existed(k string) bool

Existed func to implement the Store interface Existed method

func (*EtcdStore) Expire

func (s *EtcdStore) Expire(k string) error

Expire func to implement the Store interface Expire method

func (*EtcdStore) Get

func (s *EtcdStore) Get(k string) (string, error)

Get func to implement the Store interface Get method

func (*EtcdStore) Iter

func (s *EtcdStore) Iter(rootKey string, depth int, f IterFunc) error

Iter means to range one rootKey with it's children @depth=0 means only vist the node with assigned depth, if it's a dir, so no val would be passed. @f shoule be goroutine safe.

func (*EtcdStore) Set

func (s *EtcdStore) Set(k, v string, expire time.Duration) error

Set func to implement the Store interface Set method expire <= 0 are ignored. Given that the zero-value is ignored, TTL cannot be used to set a TTL of 0.

type IterFunc

type IterFunc func(key, val string, isDir bool)

IterFunc to visit a node in s.Iter

type OpCode

type OpCode uint8

OpCode ...

const (
	// SetOp Update operation
	SetOp OpCode = iota + 1
	// DeleteOp Delete operation
	DeleteOp
	// ExpireOp Expire operation
	ExpireOp
)

type Watcher

type Watcher struct {
	Kapi client.KeysAPI
	// contains filtered or unexported fields
}

Watcher to watch the rootKey tree in etcd

func NewWatcher

func NewWatcher(kapi client.KeysAPI, duration time.Duration, rootKey string) *Watcher

NewWatcher ...

func (*Watcher) Quit

func (w *Watcher) Quit()

Quit Watch

func (*Watcher) Watch

func (w *Watcher) Watch(callback func(op OpCode, key string, value string))

Watch watch changes and notify with callback function go watcher.Watch(callbackFunc)

Jump to

Keyboard shortcuts

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