Documentation ¶
Index ¶
- Constants
- func Error(msg string)
- func Errorf(fmt string, args ...interface{})
- func New(e *store.Etcdtool) store.KVStore
- func NewClient(e *store.Etcdtool) *clientv3.Client
- func Warn(msg string)
- type KVStoreEtcd
- func (s *KVStoreEtcd) Close()
- func (s *KVStoreEtcd) Delete(key string) bool
- func (s *KVStoreEtcd) DeletePrefix(keyPrefix string) bool
- func (s *KVStoreEtcd) Deregister(serviceName string, id string, ipOrHost net.IP, port int) error
- func (s *KVStoreEtcd) DeregisterAll(serviceName string) error
- func (s *KVStoreEtcd) Exists(key string) bool
- func (s *KVStoreEtcd) Get(key string) string
- func (s *KVStoreEtcd) GetPrefix(keyPrefix string) store.KvPairs
- func (s *KVStoreEtcd) GetRootPrefix() string
- func (s *KVStoreEtcd) GetYaml(key string) interface{}
- func (s *KVStoreEtcd) IsOpen() bool
- func (s *KVStoreEtcd) LeaseKV(key string, value string, timeout int64) (err error)
- func (s *KVStoreEtcd) NameResolver(serviceName, version, what string) (net.IP, uint16, string)
- func (s *KVStoreEtcd) NameResolverAll(serviceName string, what string) (sr []*store.ServiceRecord)
- func (s *KVStoreEtcd) Open()
- func (s *KVStoreEtcd) Put(key string, value string) error
- func (s *KVStoreEtcd) PutLite(key string, value string) error
- func (s *KVStoreEtcd) PutNX(key string, value string) error
- func (s *KVStoreEtcd) PutTTL(key string, value string, seconds int64) error
- func (s *KVStoreEtcd) PutTTLLite(key string, value string, seconds int64) (err error)
- func (s *KVStoreEtcd) PutYaml(key string, value interface{}) (err error)
- func (s *KVStoreEtcd) PutYamlLite(key string, value interface{}) (err error)
- func (s *KVStoreEtcd) Register(serviceName, id, version string, ipOrHost net.IP, port int, ttl int64, ...) error
- func (s *KVStoreEtcd) SetDebug(enabled bool)
- func (s *KVStoreEtcd) SetRoot(keyPrefix string)
- func (s *KVStoreEtcd) Watch(key string, fn store.WatchFunc, stopCh chan bool) func()
- func (s *KVStoreEtcd) WatchPrefix(keyPrefix string, fn store.WatchFunc, stopCh chan bool) func()
- type MyKvPair
- type MyKvPairs
Constants ¶
View Source
const ( E3W_MODE = false DIR_TAG = "etcdv3_dir_$2H#%gRe3*t" DEFAULT_ROOT_KEY = "root" // etcd service registry root key (under DEFAULT_ROOT_KEY): SERVICE_REGISTRY_ROOT = "services" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KVStoreEtcd ¶
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 (*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) 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 ¶
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) 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) ValueString ¶
Click to show internal directories.
Click to hide internal directories.