Documentation
¶
Index ¶
- Constants
- func Error(msg string)
- func Errorf(fmt string, args ...interface{})
- func New(e *store.ConsulConfig) store.KVStore
- func NewReg() store.Registrar
- type Holder
- type KVStoreConsul
- func (s *KVStoreConsul) Acquire(lock *api.Lock, withContext func(cancelCtx context.Context), ...) (BlockFunc func())
- func (s *KVStoreConsul) Close()
- func (s *KVStoreConsul) Delete(key string) bool
- func (s *KVStoreConsul) DeletePrefix(keyPrefix string) bool
- func (s *KVStoreConsul) DeleteTTL(key string) bool
- func (s *KVStoreConsul) Deregister(serviceName string, id string, ipOrHost net.IP, port int) error
- func (s *KVStoreConsul) DeregisterAll(serviceName string) error
- func (s *KVStoreConsul) Exists(key string) bool
- func (s *KVStoreConsul) Get(key string) string
- func (s *KVStoreConsul) GetPrefix(keyPrefix string) store.KvPairs
- func (s *KVStoreConsul) GetRootPrefix() string
- func (s *KVStoreConsul) GetYaml(key string) interface{}
- func (s *KVStoreConsul) IsOpen() bool
- func (s *KVStoreConsul) LockObject(key string, value string, sessionTTL string) *api.Lock
- func (s *KVStoreConsul) LockObjectDestroy(lock *api.Lock)
- func (s *KVStoreConsul) NameResolver(serviceName, ver, what string) (net.IP, uint16, string)
- func (s *KVStoreConsul) NameResolverAll(serviceName string, what string) (sr []*store.ServiceRecord)
- func (s *KVStoreConsul) Put(key string, value string) error
- func (s *KVStoreConsul) PutLite(key string, value string) error
- func (s *KVStoreConsul) PutNX(key string, value string) error
- func (s *KVStoreConsul) PutTTL(key string, value string, seconds int64) error
- func (s *KVStoreConsul) PutTTLLite(key string, value string, seconds int64) error
- func (s *KVStoreConsul) PutYaml(key string, value interface{}) error
- func (s *KVStoreConsul) PutYamlLite(key string, value interface{}) error
- func (s *KVStoreConsul) QueryService(name string) ([]*api.CatalogService, error)
- func (s *KVStoreConsul) Register(serviceName, id, version string, ipOrHost net.IP, port int, ttl int64, ...) error
- func (s *KVStoreConsul) SetDebug(enabled bool)
- func (s *KVStoreConsul) SetRoot(keyPrefix string)
- func (s *KVStoreConsul) Unlock(lock *api.Lock)
- func (s *KVStoreConsul) Watch(key string, fn store.WatchFunc, stopCh chan bool) (blockFunc func())
- func (s *KVStoreConsul) WatchPrefix(keyPrefix string, fn store.WatchFunc, stopCh chan bool) func()
- type MyKvPair
- type MyKvPairs
- type OpFunc
Constants ¶
View Source
const ( DIR_TAG = "etcdv3_dir_$2H#%gRe3*t" ROOT_KEY = "root" CONSULAPI = "consulapi" // 一个包装consul自身的服务,为用户提供对consul自身的服务发现能力 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KVStoreConsul ¶
type KVStoreConsul struct { Client *api.Client Root string Timeout time.Duration ServiceID string // contains filtered or unexported fields }
func (*KVStoreConsul) Close ¶
func (s *KVStoreConsul) Close()
func (*KVStoreConsul) Delete ¶
func (s *KVStoreConsul) Delete(key string) bool
func (*KVStoreConsul) DeletePrefix ¶
func (s *KVStoreConsul) DeletePrefix(keyPrefix string) bool
func (*KVStoreConsul) DeleteTTL ¶
func (s *KVStoreConsul) DeleteTTL(key string) bool
func (*KVStoreConsul) Deregister ¶
func (*KVStoreConsul) DeregisterAll ¶
func (s *KVStoreConsul) DeregisterAll(serviceName string) error
func (*KVStoreConsul) Exists ¶
func (s *KVStoreConsul) Exists(key string) bool
func (*KVStoreConsul) Get ¶
func (s *KVStoreConsul) Get(key string) string
func (*KVStoreConsul) GetRootPrefix ¶
func (s *KVStoreConsul) GetRootPrefix() string
func (*KVStoreConsul) GetYaml ¶
func (s *KVStoreConsul) GetYaml(key string) interface{}
func (*KVStoreConsul) IsOpen ¶
func (s *KVStoreConsul) IsOpen() bool
func (*KVStoreConsul) LockObject ¶
Sample: s.Lock("webhook_receiver/1", "something", "10s", ) TTL 在 10s .. 24h 之间,
func (*KVStoreConsul) LockObjectDestroy ¶
func (s *KVStoreConsul) LockObjectDestroy(lock *api.Lock)
func (*KVStoreConsul) NameResolver ¶
NameResolver 返回第一个可用服务的 SVR 记录 return net.IPv4zero, 0 means there are no more targets to be found
func (*KVStoreConsul) NameResolverAll ¶
func (s *KVStoreConsul) NameResolverAll(serviceName string, what string) (sr []*store.ServiceRecord)
NameResolverAll 返回当前的全部可用服务记录列表
func (*KVStoreConsul) PutTTL ¶
func (s *KVStoreConsul) PutTTL(key string, value string, seconds int64) error
TTL 在 10s .. 24h 之间, 在 DeleteTTL() 调用之前,即使超时key也不会被K/V Store所删除,注意这一点,这并不是etcd类似的TTL特性。 也就是说,除非将隐含的lock对象Unlock了,才会删除对应的key值; 同时,也要注意到除非隐含的lock对象被lock住,才会创建对应的key值;
func (*KVStoreConsul) PutTTLLite ¶
func (s *KVStoreConsul) PutTTLLite(key string, value string, seconds int64) error
func (*KVStoreConsul) PutYaml ¶
func (s *KVStoreConsul) PutYaml(key string, value interface{}) error
func (*KVStoreConsul) PutYamlLite ¶
func (s *KVStoreConsul) PutYamlLite(key string, value interface{}) error
func (*KVStoreConsul) QueryService ¶
func (s *KVStoreConsul) QueryService(name string) ([]*api.CatalogService, error)
func (*KVStoreConsul) SetDebug ¶
func (s *KVStoreConsul) SetDebug(enabled bool)
func (*KVStoreConsul) SetRoot ¶
func (s *KVStoreConsul) SetRoot(keyPrefix string)
func (*KVStoreConsul) Unlock ¶
func (s *KVStoreConsul) Unlock(lock *api.Lock)
func (*KVStoreConsul) Watch ¶
func (s *KVStoreConsul) Watch(key string, fn store.WatchFunc, stopCh chan bool) (blockFunc func())
Watch
func (*KVStoreConsul) WatchPrefix ¶
func (s *KVStoreConsul) WatchPrefix(keyPrefix string, fn store.WatchFunc, stopCh chan bool) func()
WatchPrefix
type MyKvPair ¶
type MyKvPair struct {
// contains filtered or unexported fields
}
func (*MyKvPair) ValueString ¶
Click to show internal directories.
Click to hide internal directories.