Documentation ¶
Index ¶
- Constants
- func GenerateServiceKey(projectName string, zoneID uint32, serviceName string, serviceID uint32) string
- func GenerateWatchCommandPrefix(projectName string, zoneID uint32, serviceName string) string
- func GenerateWatchServicePrefix(projectName string) string
- func Parse(key string) (msgType string, zoneID string, serviceName string, serviceID string)
- type KV
- type Mgr
- func (p *Mgr) Del(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
- func (p *Mgr) DelRange(ctx context.Context, startKeyPrefix string, endKeyPrefix string) (*clientv3.DeleteResponse, error)
- func (p *Mgr) DelWithPrefix(ctx context.Context, keyPrefix string) (*clientv3.DeleteResponse, error)
- func (p *Mgr) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
- func (p *Mgr) GetPrefix(ctx context.Context, key string) (*clientv3.GetResponse, error)
- func (p *Mgr) GetPrefixSendIntoChan(ctx context.Context, preFix string) error
- func (p *Mgr) Handler(key string, val string) error
- func (p *Mgr) Put(ctx context.Context, key string, value string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
- func (p *Mgr) PutWithLease(ctx context.Context, key string, value string) (*clientv3.PutResponse, error)
- func (p *Mgr) Run(ctx context.Context) error
- func (p *Mgr) Start(ctx context.Context, opts ...*Options) error
- func (p *Mgr) Stop() error
- func (p *Mgr) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan
- func (p *Mgr) WatchPrefix(ctx context.Context, key string) clientv3.WatchChan
- func (p *Mgr) WatchPrefixSendIntoChan(ctx context.Context, preFix string) error
- type OnFunc
- type Options
- func (p *Options) WithAddrs(addrs []string) *Options
- func (p *Options) WithDialTimeout(dialTimeout time.Duration) *Options
- func (p *Options) WithGrantLeaseMaxRetries(retries int) *Options
- func (p *Options) WithKV(kv []KV) *Options
- func (p *Options) WithOnFunc(onFunc OnFunc) *Options
- func (p *Options) WithOutgoingEventChan(eventChan chan<- interface{}) *Options
- func (p *Options) WithTTL(ttl int64) *Options
- func (p *Options) WithWatchCommandPrefix(watchCommandPrefix string) *Options
- func (p *Options) WithWatchServicePrefix(watchServicePrefix string) *Options
Constants ¶
View Source
const ( TtlSecondDefault int64 = 33 //默认TTL时间 秒 WatchMsgTypeService string = "service" WatchMsgTypeCommand string = "command" )
Variables ¶
This section is empty.
Functions ¶
func GenerateServiceKey ¶
func GenerateServiceKey(projectName string, zoneID uint32, serviceName string, serviceID uint32) string
GenerateServiceKey 生成服务注册的key
func GenerateWatchCommandPrefix ¶
GenerateWatchCommandPrefix 生成关注命令的前缀
func GenerateWatchServicePrefix ¶
GenerateWatchServicePrefix 生成关注服务的前缀
Types ¶
type Mgr ¶
type Mgr struct {
// contains filtered or unexported fields
}
Mgr 管理器
func (*Mgr) Del ¶
func (p *Mgr) Del(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.DeleteResponse, error)
Del 删除
func (*Mgr) DelRange ¶
func (p *Mgr) DelRange(ctx context.Context, startKeyPrefix string, endKeyPrefix string) (*clientv3.DeleteResponse, error)
DelRange 按选项删除范围内的键值
func (*Mgr) DelWithPrefix ¶
func (p *Mgr) DelWithPrefix(ctx context.Context, keyPrefix string) (*clientv3.DeleteResponse, error)
DelWithPrefix 删除键值 匹配的键值
func (*Mgr) Get ¶
func (p *Mgr) Get(ctx context.Context, key string, opts ...clientv3.OpOption) (*clientv3.GetResponse, error)
Get 检索键
func (*Mgr) GetPrefixSendIntoChan ¶
GetPrefixSendIntoChan 取得关心的前缀,放入 chan 中
func (*Mgr) Put ¶
func (p *Mgr) Put(ctx context.Context, key string, value string, opts ...clientv3.OpOption) (*clientv3.PutResponse, error)
Put 将一个键值对放入etcd中
func (*Mgr) PutWithLease ¶
func (p *Mgr) PutWithLease(ctx context.Context, key string, value string) (*clientv3.PutResponse, error)
PutWithLease 将一个键值对放入etcd中 WithLease 带ttl
func (*Mgr) WatchPrefix ¶
WatchPrefix 监视以key为前缀的所有 key value
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options contains Options to configure instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.
func (*Options) WithDialTimeout ¶
func (*Options) WithGrantLeaseMaxRetries ¶
func (*Options) WithOnFunc ¶
func (*Options) WithOutgoingEventChan ¶
func (*Options) WithWatchCommandPrefix ¶
func (*Options) WithWatchServicePrefix ¶
Click to show internal directories.
Click to hide internal directories.