etcdsdk

package module
v0.0.0-...-f1fa281 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

etcd client v3 sdk

The support is as follows

  1. service discovery

  2. distributed lock

  3. data api

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ERR_NOT_NEWEST = fmt.Errorf("version is not newest")
View Source
var ERR_PARAM_INVALID = fmt.Errorf("input param is invalid")

Functions

func TimestampGet

func TimestampGet() string

func UUID

func UUID() string

Types

type AbsPath

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

func NewAbsPath

func NewAbsPath(prefix string) *AbsPath

func (*AbsPath) Coder

func (this *AbsPath) Coder(kv *KeyValue) *KeyValue

func (*AbsPath) CoderKey

func (this *AbsPath) CoderKey(key string) string

func (*AbsPath) Decoder

func (this *AbsPath) Decoder(kv *KeyValue) *KeyValue

func (*AbsPath) DecoderKey

func (this *AbsPath) DecoderKey(key string) string

func (*AbsPath) ListCoder

func (this *AbsPath) ListCoder(kv []KeyValue) []KeyValue

func (*AbsPath) ListDecoder

func (this *AbsPath) ListDecoder(kv []KeyValue) []KeyValue

type BaseAPI

type BaseAPI interface {
	NewLeaseID(ttl int) (int64, error)
	KeepLeaseID(leaseID int64) error

	PutWithLease(kv KeyValue, leaseID int64) (*KeyValue, error)
	PutWithTTL(kv KeyValue, ttl int) (*KeyValue, error)
	Put(kv KeyValue) (*KeyValue, error)

	Get(key string) (*KeyValue, error)
	GetWithChild(key string) ([]KeyValue, error)

	Del(key string) error
	Watch(key string) <-chan WatchEvent

	Lock(ctx context.Context, key string) error
	Ulock(ctx context.Context, key string) error
}

func ClientInit

func ClientInit(timeout int, endpoints []string) (BaseAPI, error)

type Client

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

func (*Client) Del

func (this *Client) Del(key string) error

func (*Client) Get

func (this *Client) Get(key string) (*KeyValue, error)

func (*Client) GetWithChild

func (this *Client) GetWithChild(key string) ([]KeyValue, error)

func (*Client) KeepLeaseID

func (this *Client) KeepLeaseID(leaseID int64) error

func (*Client) Lock

func (this *Client) Lock(ctx context.Context, key string) error

func (*Client) NewLeaseID

func (this *Client) NewLeaseID(ttl int) (int64, error)

func (*Client) Put

func (this *Client) Put(kv KeyValue) (*KeyValue, error)

func (*Client) PutWithLease

func (this *Client) PutWithLease(kv KeyValue, leaseID int64) (*KeyValue, error)

func (*Client) PutWithTTL

func (this *Client) PutWithTTL(kv KeyValue, ttl int) (*KeyValue, error)

func (*Client) Ulock

func (this *Client) Ulock(ctx context.Context, key string) error

func (*Client) Watch

func (this *Client) Watch(key string) <-chan WatchEvent

type DBAPI

type DBAPI interface {
	NewTable(name string) (TableAPI, error)
	DelTable(name string) error
}

func NewDBInit

func NewDBInit(api BaseAPI, name string) (DBAPI, error)

type DBClient

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

func (*DBClient) DelTable

func (db *DBClient) DelTable(name string) error

func (*DBClient) NewTable

func (db *DBClient) NewTable(name string) (TableAPI, error)

type EVENT_TYPE

type EVENT_TYPE int
const (
	EVENT_ADD EVENT_TYPE
	EVENT_UPDATE
	EVENT_DELETE
	EVENT_EXPIRE
)

type KeyValue

type KeyValue struct {
	Key     string
	Value   []byte
	Version int64
}

type TableAPI

type TableAPI interface {
	Insert(key string, value []byte) error
	Delete(key string) error
	Update(key string, value []byte) error

	Query() ([]KeyValue, error)
	QueryKey(key string) (*KeyValue, error)
	Watch() <-chan WatchItem
}

type WatchEvent

type WatchEvent struct {
	Event EVENT_TYPE
	KeyValue
}

type WatchItem

type WatchItem struct {
	Event EVENT_TYPE
	KeyValue
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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