Documentation ¶
Index ¶
- Constants
- func Client(config Config) (*clientv3.Client, error)
- func Close(client *clientv3.Client)
- func Compact(ctx context.Context, client *clientv3.Client, version int64) (response *clientv3.CompactResponse, err error)
- func CreateLease(ctx context.Context, client *clientv3.Client, leaseTTL int64) (*clientv3.LeaseGrantResponse, clientv3.LeaseID, error)
- func Delete(ctx context.Context, client *clientv3.Client, key string) (*clientv3.DeleteResponse, error)
- func DeleteFromKey(ctx context.Context, client *clientv3.Client, key string) (*clientv3.DeleteResponse, error)
- func DeletePrefix(ctx context.Context, client *clientv3.Client, key string) (*clientv3.DeleteResponse, error)
- func DeleteRange(ctx context.Context, client *clientv3.Client, startKey string, endKey string) (*clientv3.DeleteResponse, error)
- func Get(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetCountOnly(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetFirst(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetFirstCrt(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetFirstRevision(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetFromKey(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetKeysOnly(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetLast(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetLastCrt(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetLastRevision(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetLimit(ctx context.Context, client *clientv3.Client, key string, num int64) (*clientv3.GetResponse, map[string]string, error)
- func GetMaxCrtRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
- func GetMaxModRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
- func GetMinCrtRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
- func GetMinModRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
- func GetPrefix(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func GetRange(ctx context.Context, client *clientv3.Client, startKey string, endKey string) (*clientv3.GetResponse, map[string]string, error)
- func GetRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
- func GetWithSorted(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
- func KeepAliveAways(ctx context.Context, client *clientv3.Client, leaseID clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error)
- func KeepAliveOnce(ctx context.Context, client *clientv3.Client, leaseID clientv3.LeaseID) (*clientv3.LeaseKeepAliveResponse, error)
- func LeaseTimeToLive(ctx context.Context, client *clientv3.Client, leaseID clientv3.LeaseID) (*clientv3.LeaseTimeToLiveResponse, map[string]string, error)
- func Put(ctx context.Context, client *clientv3.Client, key string, value string) (*clientv3.PutResponse, error)
- func PutWithLease(ctx context.Context, client *clientv3.Client, key string, value string, ...) (*clientv3.PutResponse, error)
- func RevokeLease(ctx context.Context, client *clientv3.Client, leaseID clientv3.LeaseID) (*clientv3.LeaseRevokeResponse, error)
- func TxnDelete(ctx context.Context, client *clientv3.Client, KVList map[string]string) (*clientv3.TxnResponse, error)
- func TxnPut(ctx context.Context, client *clientv3.Client, KVList map[string]string) (*clientv3.TxnResponse, error)
- func TxnPutWithLease(ctx context.Context, client *clientv3.Client, KVList map[string]string, ...) (*clientv3.TxnResponse, error)
- func Watch(ctx context.Context, client *clientv3.Client, key string, data chan WatchData, ...)
- func WatchPrefix(ctx context.Context, client *clientv3.Client, key string, data chan WatchData, ...)
- func WatchRange(ctx context.Context, client *clientv3.Client, keyOne string, keyTwo string, ...)
- func WatchWithProgressNotify(ctx context.Context, client *clientv3.Client, key string, data chan WatchData)
- type Config
- type WatchData
Constants ¶
const ( MethodCreate = "create" MethodModify = "modify" MethodDelete = "delete" MethodPut = "put" )
操作类型
Variables ¶
This section is empty.
Functions ¶
func Compact ¶
func Compact(ctx context.Context, client *clientv3.Client, version int64) (response *clientv3.CompactResponse, err error)
Compact compacts etcd KV history before the given rev. (为了避免积累无限数量的历史数据,压缩过往的修订版本功能很重要。 压缩之后,etcd删除历史修订版本,释放资源来提供未来使用。 所有修订版本在压缩修订版本之前的被替代的数据将不可访问).
func CreateLease ¶
func CreateLease(ctx context.Context, client *clientv3.Client, leaseTTL int64) (*clientv3.LeaseGrantResponse, clientv3.LeaseID, error)
CreateLease create a lease id.
func Delete ¶
func Delete(ctx context.Context, client *clientv3.Client, key string) (*clientv3.DeleteResponse, error)
Delete 删除一个key-value对.
func DeleteFromKey ¶
func DeleteFromKey(ctx context.Context, client *clientv3.Client, key string) (*clientv3.DeleteResponse, error)
DeleteFromKey 删除所有匹配>=给定key(使用byte比较)的key-value对.
func DeletePrefix ¶
func DeletePrefix(ctx context.Context, client *clientv3.Client, key string) (*clientv3.DeleteResponse, error)
DeletePrefix 删除所有前缀匹配要求的key-value对.
func DeleteRange ¶
func DeleteRange(ctx context.Context, client *clientv3.Client, startKey string, endKey string) (*clientv3.DeleteResponse, error)
DeleteRange 删除所有匹配[startKey, endKey)的key-value对.
func Get ¶
func Get(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
Get 获取key对应的value.
func GetCountOnly ¶
func GetCountOnly(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetCountOnly get keys return only the count of keys.
func GetFirst ¶
func GetFirst(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetFirst gets the lexically first key in the request range.
func GetFirstCrt ¶
func GetFirstCrt(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetFirstCrt gets the key with the oldest creation revision in the request range.
func GetFirstRevision ¶
func GetFirstRevision(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetFirstRevision gets the key with the oldest modification revision in the request range.
func GetFromKey ¶
func GetFromKey(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetFromKey get keys that are greater than or equal to the given key using byte compare.
func GetKeysOnly ¶
func GetKeysOnly(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetKeysOnly get key return only the keys and the corresponding values will be omitted.
func GetLast ¶
func GetLast(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetLast gets the lexically last key in the request range.
func GetLastCrt ¶
func GetLastCrt(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetLastCrt gets the key with the latest creation revision in the request range.
func GetLastRevision ¶
func GetLastRevision(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetLastRevision gets the key with the latest modification revision in the request range.
func GetLimit ¶
func GetLimit(ctx context.Context, client *clientv3.Client, key string, num int64) (*clientv3.GetResponse, map[string]string, error)
GetLimit 获取限定最大数量的key-value对.
func GetMaxCrtRevision ¶
func GetMaxCrtRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
GetMaxCrtRevision get key filters out keys for Get with creation revisions greater than the given revision.
func GetMaxModRevision ¶
func GetMaxModRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
GetMaxModRevision get key filters out keys for Get with modification revisions greater than the given revision.
func GetMinCrtRevision ¶
func GetMinCrtRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
GetMinCrtRevision get key filters out keys for Get with creation revisions less than the given revision.
func GetMinModRevision ¶
func GetMinModRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
GetMinModRevision get key filters out keys for Get with modification revisions less than the given revision.
func GetPrefix ¶
func GetPrefix(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetPrefix 获取所有前缀匹配key的key-value对.
func GetRange ¶
func GetRange(ctx context.Context, client *clientv3.Client, startKey string, endKey string) (*clientv3.GetResponse, map[string]string, error)
GetRange get keys which in [startKey, endKey).
func GetRevision ¶
func GetRevision(ctx context.Context, client *clientv3.Client, key string, revision int64) (*clientv3.GetResponse, map[string]string, error)
GetRevision 获取制定revision的key-value对.
func GetWithSorted ¶
func GetWithSorted(ctx context.Context, client *clientv3.Client, key string) (*clientv3.GetResponse, map[string]string, error)
GetWithSorted 获取前缀匹配key的key-value对,结果已排序.
func KeepAliveAways ¶
func KeepAliveAways(ctx context.Context, client *clientv3.Client, leaseID clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error)
KeepAliveAways keep a lease aways.
func KeepAliveOnce ¶
func KeepAliveOnce(ctx context.Context, client *clientv3.Client, leaseID clientv3.LeaseID) (*clientv3.LeaseKeepAliveResponse, error)
KeepAliveOnce keep a lease once.
func LeaseTimeToLive ¶
func LeaseTimeToLive(ctx context.Context, client *clientv3.Client, leaseID clientv3.LeaseID) (*clientv3.LeaseTimeToLiveResponse, map[string]string, error)
LeaseTimeToLive retrieves the lease information of the given lease ID.
func Put ¶
func Put(ctx context.Context, client *clientv3.Client, key string, value string) (*clientv3.PutResponse, error)
Put a key-value pair.
func PutWithLease ¶
func PutWithLease(ctx context.Context, client *clientv3.Client, key string, value string, leaseID clientv3.LeaseID) (*clientv3.PutResponse, error)
PutWithLease a key-value pair with lease.
func RevokeLease ¶
func RevokeLease(ctx context.Context, client *clientv3.Client, leaseID clientv3.LeaseID) (*clientv3.LeaseRevokeResponse, error)
RevokeLease revoke a lease. 撤销租约,等同于租约到期,关联的节点都会被删除
func TxnDelete ¶
func TxnDelete(ctx context.Context, client *clientv3.Client, KVList map[string]string) (*clientv3.TxnResponse, error)
TxnDelete txn multi delete.
func TxnPut ¶
func TxnPut(ctx context.Context, client *clientv3.Client, KVList map[string]string) (*clientv3.TxnResponse, error)
TxnPut txn multi write.
func TxnPutWithLease ¶
func TxnPutWithLease(ctx context.Context, client *clientv3.Client, KVList map[string]string, leaseID clientv3.LeaseID) (*clientv3.TxnResponse, error)
TxnPutWithLease txn multi lease.
func Watch ¶
func Watch(ctx context.Context, client *clientv3.Client, key string, data chan WatchData, stopCh chan struct{})
Watch a key change event.
func WatchPrefix ¶
func WatchPrefix(ctx context.Context, client *clientv3.Client, key string, data chan WatchData, stopCh chan struct{})
WatchPrefix a prefix key change event.
Types ¶
type Config ¶
type Config struct { NodeList []string `json:"nodeList"` UseTLS bool `json:"userTLS"` CaFile string `json:"ca"` CertFile string `json:"cert"` CertKeyFile string `json:"key"` ServerName string `json:"serverName"` DialTimeout time.Duration `json:"timeout"` // per - Millisecond DialKeepAlivePeriod time.Duration `json:"keepAlivePeriod"` // per - Millisecond DialKeepAliveTimeout time.Duration `json:"keepAliveTimeout"` // per - Millisecond }
Config etcd配置