etcd

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cli

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

func NewEtcdClient

func NewEtcdClient(endpoints []string, userName, password string) (*Cli, error)

new a etcd client

func (*Cli) Delete

func (cli *Cli) Delete(ctx context.Context, key string) error

delete a key

func (*Cli) DeleteWithPrefix

func (cli *Cli) DeleteWithPrefix(ctx context.Context, key string) error

delete with prefix

func (*Cli) KeepAlive

func (cli *Cli) KeepAlive(ctx context.Context, key, value string, ttl int64) (clientv3.LeaseID, error)

keep alive once with key

func (*Cli) KeepAliveOnce

func (cli *Cli) KeepAliveOnce(ctx context.Context, key, value string, ttl int64) error

keep alive once with key

func (*Cli) Put

func (cli *Cli) Put(ctx context.Context, key, value string) error

put a key with value

func (*Cli) PutWithNotExist

func (cli *Cli) PutWithNotExist(ctx context.Context, key, value string) (bool, error)

put not exist key

func (*Cli) Revoke

func (cli *Cli) Revoke(ctx context.Context, id clientv3.LeaseID) error

revoke lease

func (*Cli) Watch

func (cli *Cli) Watch(ctx context.Context, key string) *WatchKeyResponse

func (*Cli) WatchWithPrefix

func (cli *Cli) WatchWithPrefix(ctx context.Context, prefix string) *WatchKeyResponse

watch with prefix

type EventType

type EventType int32
const (
	CreateKeyChangeEvent EventType = 1
	UpdateKeyChangeEvent EventType = 2
	DeleteKeyChangeEvent EventType = 3
)

type KeyChangeEvent

type KeyChangeEvent struct {
	Type  EventType
	Key   []byte
	Value []byte
}

type WatchKeyResponse

type WatchKeyResponse struct {
	Watcher clientv3.Watcher
	Id      clientv3.LeaseID
	Event   <-chan *KeyChangeEvent
}

Jump to

Keyboard shortcuts

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