etcd

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Overview

Package etcd 是 jsonstore 使用 etcd 作为 backend 的实现

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpOption

type OpOption func(*Option)

func WithEndpoints

func WithEndpoints(endpoints []string) OpOption

type Option

type Option struct {
	Endpoints []string
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store etcd backend 的 storetypes.Store 实现

func New

func New(ops ...OpOption) (*Store, error)

New creates a etcd store with etcd client, be used to access the etcd cluster.

func (*Store) Get

func (s *Store) Get(pctx context.Context, key string) (storetypes.KeyValue, error)

Get returns the value of the key.

func (*Store) GetClient

func (s *Store) GetClient() *clientv3.Client

GetClient 获取 Store 内部的 etcd client

func (*Store) NewSTM

func (s *Store) NewSTM(f func(stm stm.JSONStoreSTMOP) error) error

NewSTM etcd concurrency.NewSTM + json (un)marshal

func (*Store) PrefixGet

func (s *Store) PrefixGet(pctx context.Context, prefix string) ([]storetypes.KeyValue, error)

PrefixGet returns the all key value with specify prefix.

func (*Store) PrefixGetKey

func (s *Store) PrefixGetKey(pctx context.Context, prefix string) ([]storetypes.Key, error)

PrefixGetKey 只获取 key

func (*Store) PrefixRemove

func (s *Store) PrefixRemove(pctx context.Context, prefix string) ([]storetypes.KeyValue, error)

PrefixRemove 删除 prefix 开头的所有 kv

func (*Store) Put

func (s *Store) Put(pctx context.Context, key, value string) error

Put writes the keyvalue pair into etcd.

func (*Store) PutWithOption

func (s *Store) PutWithOption(ctx context.Context, key, value string, opts []interface{}) (interface{}, error)

PutWithOption 向 etcd 写入 kv 时能指定 option

func (*Store) PutWithRev

func (s *Store) PutWithRev(ctx context.Context, key, value string) (int64, error)

PutWithRev 向 etcd 写入 kv,并且返回 revision

func (*Store) Remove

func (s *Store) Remove(pctx context.Context, key string) (*storetypes.KeyValue, error)

Remove 删除一个 keyvalue, 同时返回被删除的 kv 对象.

func (*Store) Watch

func (s *Store) Watch(ctx context.Context, key string, isPrefix, filterDelete bool) (storetypes.WatchChan, error)

Watch key 的变化,如果 filterDelete=true,则忽略删除事件

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL