gxetcd

package
v1.11.11 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: Apache-2.0 Imports: 9 Imported by: 23

Documentation

Index

Constants

View Source
const (
	// ConnDelay connection delay
	ConnDelay = 3
	// MaxFailTimes max failure times
	MaxFailTimes = 15
	// RegistryETCDV3Client client Name
	RegistryETCDV3Client = "etcd registry"
	// MetadataETCDV3Client client Name
	MetadataETCDV3Client = "etcd metadata"
)

Variables

View Source
var (
	// ErrNilETCDV3Client raw client nil
	ErrNilETCDV3Client = perrors.New("etcd raw client is nil") // full describe the ERR
	// ErrKVPairNotFound not found key
	ErrKVPairNotFound = perrors.New("k/v pair not found")
	// ErrKVListSizeIllegal k/v list empty or not equal size
	ErrKVListSizeIllegal = perrors.New("k/v List is empty or kList's size is not equal to the size of vList")
	// ErrCompareFail txn compare fail
	ErrCompareFail = perrors.New("txn compare fail")
	// ErrRevision revision when error
	ErrRevision int64 = -1
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Wait sync.WaitGroup
	// contains filtered or unexported fields
}

Client represents etcd client Configuration

func NewClient

func NewClient(name string, endpoints []string, timeout time.Duration, heartbeat int) (*Client, error)

NewClient create a client instance with name, endpoints etc.

func NewConfigClient

func NewConfigClient(opts ...Option) *Client

NewConfigClient create new Client

func NewConfigClientWithErr added in v1.11.8

func NewConfigClientWithErr(opts ...Option) (*Client, error)

NewConfigClientWithErr create new Client,error

func (*Client) BatchCreate added in v1.11.8

func (c *Client) BatchCreate(kList []string, vList []string) error

BatchCreate bulk insertion

func (*Client) CleanKV

func (c *Client) CleanKV() error

CleanKV delete all key and value

func (*Client) Close

func (c *Client) Close()

Close close client

func (*Client) Create

func (c *Client) Create(k string, v string) error

Create key value ...

func (*Client) Delete

func (c *Client) Delete(k string) error

Delete key

func (*Client) Done

func (c *Client) Done() <-chan struct{}

Done return exit chan

func (*Client) Get

func (c *Client) Get(k string) (string, error)

Get gets value by @k

func (*Client) GetChildren added in v1.11.3

func (c *Client) GetChildren(k string) ([]string, []string, error)

GetChildren return node children

func (*Client) GetChildrenKVList

func (c *Client) GetChildrenKVList(k string) ([]string, []string, error)

GetChildrenKVList gets children kv list by @k

func (*Client) GetCtx added in v1.11.3

func (c *Client) GetCtx() context.Context

GetCtx return client context

func (*Client) GetEndPoints added in v1.11.3

func (c *Client) GetEndPoints() []string

GetEndPoints return etcd endpoints

func (*Client) GetRawClient added in v1.11.3

func (c *Client) GetRawClient() *clientv3.Client

GetRawClient return etcd raw client

func (*Client) GetValAndRev added in v1.11.8

func (c *Client) GetValAndRev(k string) (string, int64, error)

GetValAndRev gets value and revision by @k

func (*Client) Put added in v1.11.9

func (c *Client) Put(k, v string, opts ...clientv3.OpOption) error

Put key value ...

func (*Client) RegisterTemp

func (c *Client) RegisterTemp(k, v string) error

RegisterTemp registers a temporary node

func (*Client) Update

func (c *Client) Update(k, v string) error

Update key value ...

func (*Client) UpdateWithRev added in v1.11.8

func (c *Client) UpdateWithRev(k, v string, rev int64, opts ...clientv3.OpOption) error

Update key value ...

func (*Client) Valid

func (c *Client) Valid() bool

Valid check client

func (*Client) Watch

func (c *Client) Watch(k string) (clientv3.WatchChan, error)

Watch watches on spec key

func (*Client) WatchWithOption added in v1.11.8

func (c *Client) WatchWithOption(k string, opts ...clientv3.OpOption) (clientv3.WatchChan, error)

Watch watches on spc key with OpOption

func (*Client) WatchWithPrefix

func (c *Client) WatchWithPrefix(prefix string) (clientv3.WatchChan, error)

WatchWithPrefix watches on spec prefix

type Option

type Option func(*Options)

Option will define a function of handling Options

func WithEndpoints

func WithEndpoints(endpoints ...string) Option

WithEndpoints sets etcd client endpoints

func WithHeartbeat

func WithHeartbeat(heartbeat int) Option

WithHeartbeat sets etcd client heartbeat

func WithName

func WithName(name string) Option

WithName sets etcd client name

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets etcd client timeout

type Options

type Options struct {
	// Name etcd server name
	Name string
	// Endpoints etcd endpoints
	Endpoints []string
	// Client etcd client
	Client *Client
	// Timeout timeout
	Timeout time.Duration
	// Heartbeat second
	Heartbeat int
}

Options client configuration

Jump to

Keyboard shortcuts

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