etcd

package
v0.0.0-...-ae08a2b Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyCreateChangeEvent = iota + 1 //  create event
	KeyUpdateChangeEvent            //  update event
	KeyDeleteChangeEvent            //  delete event
	KeyCancelChangeEvent            //  cancel event

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cli

type Cli struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

etcd cli

func NewEtcdCli

func NewEtcdCli(config *CliConfig) (*Cli, error)

new etcd cli

func (*Cli) Campaign

func (cli *Cli) Campaign(ctx context.Context, id, prefix string, ttl int64) error

campaign become leader

func (*Cli) Delete

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

delete a key

func (*Cli) Get

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

get with key

func (*Cli) GetWithPrefix

func (cli *Cli) GetWithPrefix(ctx context.Context, prefix string) ([]string, []string, error)

get with prefix

func (*Cli) Keepalive

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

func (*Cli) Leader

func (cli *Cli) Leader(ctx context.Context, prefix string) (id string, err error)

find leader

func (*Cli) Put

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

put a key

func (*Cli) PutWithNotExist

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

func (*Cli) PutWithNotExistTTL

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

func (*Cli) PutWithTTL

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

put a key with ttl

func (*Cli) Revoke

func (cli *Cli) Revoke(ctx context.Context, leaseId int64) error

func (*Cli) Transfer

func (cli *Cli) Transfer(ctx context.Context, from, to string, value string) error

transfer a key

func (*Cli) Watch

func (cli *Cli) Watch(key string) *WatchKeyResponse

func (*Cli) WatchWithPrefix

func (cli *Cli) WatchWithPrefix(prefix string) *WatchKeyResponse

type CliConfig

type CliConfig struct {
	Endpoints   []string
	UserName    string
	Password    string
	DialTimeout time.Duration
}

etcd cli config

type KeyChange

type KeyChange struct {
	Event KeyChangeEvent
	Key   string
	Value string
}

type KeyChangeChan

type KeyChangeChan <-chan *KeyChange

type KeyChangeEvent

type KeyChangeEvent int32

type WatchKeyResponse

type WatchKeyResponse struct {
	Watcher     clientv3.Watcher
	KeyChangeCh chan *KeyChange
}

Jump to

Keyboard shortcuts

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