etcdv3

package
v1.5.5-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 13 Imported by: 1

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 (
	// Defines related errors
	ErrNilETCDV3Client = perrors.New("etcd raw client is nil") // full describe the ERR
	ErrKVPairNotFound  = perrors.New("k/v pair not found")
)

Functions

func HandleClientRestart

func HandleClientRestart(r clientFacade)

HandleClientRestart keeps the connection between client and server

func ValidateClient

func ValidateClient(container clientFacade, opts ...Option) error

ValidateClient validates client and sets options

Types

type Client

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

Client represents etcd client Configuration

func NewClient added in v1.5.0

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

nolint

func NewServiceDiscoveryClient added in v1.5.0

func NewServiceDiscoveryClient(opts ...Option) *Client

nolint

func (*Client) CleanKV

func (c *Client) CleanKV() error

nolint

func (*Client) Close

func (c *Client) Close()

nolint

func (*Client) Create

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

nolint

func (*Client) Delete

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

nolint

func (*Client) Done

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

nolint

func (*Client) Get

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

Get gets value by @k

func (*Client) GetChildrenKVList

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

GetChildrenKVList gets children kv list by @k

func (*Client) RegisterTemp

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

RegisterTemp registers a temporary node

func (*Client) Update added in v1.5.0

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

Update key value ...

func (*Client) Valid

func (c *Client) Valid() bool

nolint

func (*Client) Watch

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

Watch watches on spec key

func (*Client) WatchWithPrefix

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

WatchWithPrefix watches on spec prefix

type EventListener

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

nolint

func NewEventListener

func NewEventListener(client *Client) *EventListener

NewEventListener returns a EventListener instance

func (*EventListener) Close

func (l *EventListener) Close()

nolint

func (*EventListener) ListenServiceEvent

func (l *EventListener) ListenServiceEvent(key string, listener remoting.DataListener)

ListenServiceEvent is invoked by etcdv3 ConsumerRegistry::Registe/ etcdv3 ConsumerRegistry::get/etcdv3 ConsumerRegistry::getListener registry.go:Listen -> listenServiceEvent -> listenDirEvent -> listenServiceNodeEvent

|
--------> listenServiceNodeEvent

func (*EventListener) ListenServiceNodeEvent

func (l *EventListener) ListenServiceNodeEvent(key string, listener ...remoting.DataListener) bool

listenServiceNodeEvent Listen on a spec key this method will return true when spec key deleted, this method will return false when deep layer connection lose

func (*EventListener) ListenServiceNodeEventWithPrefix

func (l *EventListener) ListenServiceNodeEventWithPrefix(prefix string, listener ...remoting.DataListener)

ListenServiceNodeEventWithPrefix listens on a set of key with 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 {
	// contains filtered or unexported fields
}

nolint

Jump to

Keyboard shortcuts

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