etcd

package
v1.8.80 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

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

NewClient 创建一个新的 Client 实例

func (*Client) AcquireLock

func (c *Client) AcquireLock(lockName string) (*concurrency.Mutex, *concurrency.Session, error)

AcquireLock 分布式锁

func (*Client) Close

func (c *Client) Close() error

Close 关闭连接

func (*Client) Connect

func (c *Client) Connect() error

Connect 建立连接

func (*Client) CreateLease

func (c *Client) CreateLease(ttl int64) (cliv3.LeaseID, error)

CreateLease 租约管理

func (*Client) Get

func (c *Client) Get(key string, prefix bool) (map[string]string, error)

Get 获取单个键或服务

func (*Client) KeepAliveLease

func (c *Client) KeepAliveLease(id cliv3.LeaseID) error

KeepAliveLease 保持租约激活

func (*Client) ListMembers

func (c *Client) ListMembers() error

ListMembers 成员管理

func (*Client) Put

func (c *Client) Put(key, value string) error

Put 放置/更新

func (*Client) RegisterService

func (c *Client) RegisterService(serviceName, serviceAddr string, ttl int64) (cliv3.LeaseID, error)

RegisterService 注册服务

func (*Client) ReleaseLock

func (c *Client) ReleaseLock(m *concurrency.Mutex, s *concurrency.Session) error

ReleaseLock 释放锁

func (*Client) Txn

func (c *Client) Txn() error

Txn 事务示例代码

func (*Client) Watch

func (c *Client) Watch(key string, prefix bool)

Watch 监听 withPrefix用来监听服务:"/services/xxx"

Jump to

Keyboard shortcuts

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