etcd

package
v0.0.0-...-532f4bb Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EtcdClient

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

func InitEtcdClient

func InitEtcdClient(c *EtcdConfig) (*EtcdClient, error)

func (*EtcdClient) Close

func (cli *EtcdClient) Close() error

func (*EtcdClient) Delete

func (cli *EtcdClient) Delete(key string, timeout time.Duration) error

func (*EtcdClient) GetMetadata

func (cli *EtcdClient) GetMetadata(key string, timeout time.Duration) (string, error)

func (*EtcdClient) GetNodes

func (cli *EtcdClient) GetNodes(key string, timeout time.Duration) ([]string, error)

func (*EtcdClient) Lock

func (cli *EtcdClient) Lock(key, val string, ttl int64) (*LockResult, error)

etcd 分布式锁

func (*EtcdClient) Put

func (cli *EtcdClient) Put(key, metadata string, timeout time.Duration) error

func (*EtcdClient) Unlock

func (cli *EtcdClient) Unlock(res *LockResult)

func (*EtcdClient) Update

func (cli *EtcdClient) Update(key, update string, timeout time.Duration) (string, error)

func (*EtcdClient) Watch

func (cli *EtcdClient) Watch(key string, cb func(int32, string, string))

type EtcdConfig

type EtcdConfig struct {
	Endpoints   []string      `json:"endpoints"`
	DialTimeout time.Duration `json:"dialTimeout"`
}

type LockResult

type LockResult struct {
	IsLock  bool
	LeaseID clientv3.LeaseID
	Cancel  context.CancelFunc
}

Jump to

Keyboard shortcuts

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