Version: v0.0.0-...-276be26 Latest Latest

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

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 23 Imported by: 0




View Source
const (
	E3W_MODE         = false
	DIR_TAG          = "etcdv3_dir_$2H#%gRe3*t"

	// etcd service registry root key (under DEFAULT_ROOT_KEY):


This section is empty.


func Error

func Error(msg string)

func Errorf

func Errorf(fmt string, args ...interface{})

func New

func New(e *store.Etcdtool) store.KVStore

func NewClient

func NewClient(e *store.Etcdtool) *clientv3.Client

func Warn

func Warn(msg string)

Warn() just for testing.


type KVStoreEtcd

type KVStoreEtcd struct {
	Client *clientv3.Client
	// contains filtered or unexported fields

func (*KVStoreEtcd) Close

func (s *KVStoreEtcd) Close()

func (*KVStoreEtcd) Delete

func (s *KVStoreEtcd) Delete(key string) bool

func (*KVStoreEtcd) DeletePrefix

func (s *KVStoreEtcd) DeletePrefix(keyPrefix string) bool

func (*KVStoreEtcd) Deregister

func (s *KVStoreEtcd) Deregister(serviceName string, id string, ipOrHost net.IP, port int) error

func (*KVStoreEtcd) DeregisterAll

func (s *KVStoreEtcd) DeregisterAll(serviceName string) error

func (*KVStoreEtcd) Exists

func (s *KVStoreEtcd) Exists(key string) bool

func (*KVStoreEtcd) Get

func (s *KVStoreEtcd) Get(key string) string

func (*KVStoreEtcd) GetPrefix

func (s *KVStoreEtcd) GetPrefix(keyPrefix string) store.KvPairs

func (*KVStoreEtcd) GetRootPrefix

func (s *KVStoreEtcd) GetRootPrefix() string

func (*KVStoreEtcd) GetYaml

func (s *KVStoreEtcd) GetYaml(key string) interface{}

func (*KVStoreEtcd) IsOpen

func (s *KVStoreEtcd) IsOpen() bool

func (*KVStoreEtcd) LeaseKV

func (s *KVStoreEtcd) LeaseKV(key string, value string, timeout int64) (err error)

func (*KVStoreEtcd) NameResolver

func (s *KVStoreEtcd) NameResolver(serviceName, version, what string) (net.IP, uint16, string)

NameResolver etcd 服务发现框架:服务的每个实例注册自己到etcd, 且定时更新自己。 注册信息需要带有TTL,通常约定为 5s, 10s, 30s 等值。

func (*KVStoreEtcd) NameResolverAll

func (s *KVStoreEtcd) NameResolverAll(serviceName string, what string) (sr []*store.ServiceRecord)

NameResolverAll 返回当前的全部可用服务记录列表

func (*KVStoreEtcd) Open

func (s *KVStoreEtcd) Open()

func (*KVStoreEtcd) Put

func (s *KVStoreEtcd) Put(key string, value string) error

func (*KVStoreEtcd) PutLite

func (s *KVStoreEtcd) PutLite(key string, value string) error

func (*KVStoreEtcd) PutNX

func (s *KVStoreEtcd) PutNX(key string, value string) error

func (*KVStoreEtcd) PutTTL

func (s *KVStoreEtcd) PutTTL(key string, value string, seconds int64) error

func (*KVStoreEtcd) PutTTLLite

func (s *KVStoreEtcd) PutTTLLite(key string, value string, seconds int64) (err error)

func (*KVStoreEtcd) PutYaml

func (s *KVStoreEtcd) PutYaml(key string, value interface{}) (err error)

func (*KVStoreEtcd) PutYamlLite

func (s *KVStoreEtcd) PutYamlLite(key string, value interface{}) (err error)

func (*KVStoreEtcd) Register

func (s *KVStoreEtcd) Register(serviceName, id, version string, ipOrHost net.IP, port int, ttl int64, tags []string, meta map[string]interface{}, moreChecks api.AgentServiceChecks) error

Register in etcd, it register main restful service with ip+port, and register gRPC port implicitly.

func (*KVStoreEtcd) SetDebug

func (s *KVStoreEtcd) SetDebug(enabled bool)

func (*KVStoreEtcd) SetRoot

func (s *KVStoreEtcd) SetRoot(keyPrefix string)

func (*KVStoreEtcd) Watch

func (s *KVStoreEtcd) Watch(key string, fn store.WatchFunc, stopCh chan bool) func()

Watch 启动一个监视线程。etcd.Watch。 stopCh被用于阻塞 blockFunc,并接收信号以结束该线程的阻塞。 stopCh为nil时,阻塞线程失效,而且并不需要其存在,这一特殊场景仅仅适用于etcd的Watch机制。

func (*KVStoreEtcd) WatchPrefix

func (s *KVStoreEtcd) WatchPrefix(keyPrefix string, fn store.WatchFunc, stopCh chan bool) func()

type MyKvPair

type MyKvPair struct {
	Key1 []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// create_revision is the revision of last creation on this key.
	CreateRevision int64 `protobuf:"varint,2,opt,name=create_revision,json=createRevision,proto3" json:"create_revision,omitempty"`
	// mod_revision is the revision of last modification on this key.
	ModRevision int64 `protobuf:"varint,3,opt,name=mod_revision,json=modRevision,proto3" json:"mod_revision,omitempty"`
	// version is the version of the key. A deletion resets
	// the version to zero and any modification of the key
	// increases its version.
	Version int64 `protobuf:"varint,4,opt,name=version,proto3" json:"version,omitempty"`
	// value is the value held by the key, in bytes.
	Value1 []byte `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"`
	// lease is the ID of the lease that attached to key.
	// When the attached lease expires, the key will be deleted.
	// If lease is 0, then no lease is attached to the key.
	Lease int64 `protobuf:"varint,6,opt,name=lease,proto3" json:"lease,omitempty"`

func (*MyKvPair) Key

func (s *MyKvPair) Key() string

func (*MyKvPair) Value

func (s *MyKvPair) Value() []byte

func (*MyKvPair) ValueString

func (s *MyKvPair) ValueString() string

type MyKvPairs

type MyKvPairs struct {
	// contains filtered or unexported fields

func (*MyKvPairs) Count

func (s *MyKvPairs) Count() int

func (*MyKvPairs) Item

func (s *MyKvPairs) Item(index int) store.KvPair

Jump to

Keyboard shortcuts

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