Documentation ¶
Overview ¶
====================================================
# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : etcd.go # Created : 2019-01-29 11:48:14 # Describe : # # ====================================================
Index ¶
- Constants
- type Etcd
- func (s *Etcd) AtomicDelete(ctx context.Context, key string, previous *store.KVPair) (bool, *store.KVPair, error)
- func (s *Etcd) AtomicPut(ctx context.Context, key string, value []byte, previous *store.KVPair, ...) (bool, *store.KVPair, error)
- func (s *Etcd) Close() error
- func (s *Etcd) Delete(ctx context.Context, key string) error
- func (s *Etcd) DeleteTree(ctx context.Context, directory string) error
- func (s *Etcd) Exists(ctx context.Context, key string) (bool, error)
- func (s *Etcd) Get(ctx context.Context, key string) (*store.KVPair, error)
- func (s *Etcd) List(ctx context.Context, directory string) ([]*store.KVPair, error)
- func (s *Etcd) NewLock(key string, options *store.LockOptions) (store.Locker, error)
- func (s *Etcd) NewNonBlockLocker(key string, options *store.LockOptions) store.NonBlockLocker
- func (s *Etcd) Put(ctx context.Context, key string, value []byte, opts *store.WriteOptions) error
- func (s *Etcd) Watch(ctx context.Context, key string, stopCh <-chan struct{}) (<-chan *store.WatchRes, error)
- func (s *Etcd) WatchTree(ctx context.Context, directory string, stopCh <-chan struct{}) (<-chan *store.WatchRes, error)
Constants ¶
View Source
const (
// DefaultLockKey 锁的默认key
DefaultLockKey = "mutex/lock/key"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Etcd ¶
type Etcd struct {
// contains filtered or unexported fields
}
Etcd implements Store
func (*Etcd) AtomicDelete ¶
func (s *Etcd) AtomicDelete(ctx context.Context, key string, previous *store.KVPair) (bool, *store.KVPair, error)
AtomicDelete 删除该键的值,如果这个键被同时修改,抛出一个错误
func (*Etcd) AtomicPut ¶
func (s *Etcd) AtomicPut(ctx context.Context, key string, value []byte, previous *store.KVPair, opts *store.WriteOptions) (bool, *store.KVPair, error)
AtomicPut 更新一个值在“键”,如果被键同时修改,则抛出错误 如果操作失败,它将返回(false, previous, error (if err != nil)) 如果操作成功,它将返回(true, nil, nil)
func (*Etcd) DeleteTree ¶
DeleteTree 产出directory下所有的键值
func (*Etcd) NewNonBlockLocker ¶
func (s *Etcd) NewNonBlockLocker(key string, options *store.LockOptions) store.NonBlockLocker
NewNonBlockLocker 返回一个非阻塞分布式锁
Click to show internal directories.
Click to hide internal directories.