zookeeper

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ACL

type ACL struct {
	Scheme   string `yaml:"scheme" json:"scheme" ini:"scheme"`       // 认证方案(digest/sasl)
	Password string `yaml:"password" json:"password" ini:"password"` // 认证密码
}

ACL 认证信息结构体

type Client

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

Client 封装的Zookeeper客户端

func (*Client) Close

func (c *Client) Close()

Close 关闭客户端

func (*Client) CreateEphemeral

func (c *Client) CreateEphemeral(path string, data []byte) error

CreateEphemeral 创建临时节点并记录以便重建

func (*Client) DeleteEphemeral

func (c *Client) DeleteEphemeral(path string) error

DeleteEphemeral 删除临时节点并从重建列表中移除

func (*Client) GetConn

func (c *Client) GetConn() *zk.Conn

GetConn 获取当前活跃的连接(线程安全)

type Config

type Config struct {
	Addrs           []string        `yaml:"addrs" json:"addrs" ini:"addrs"`                                  // ZK集群地址,格式:["host1:2181", "host2:2181"]
	SessionTimeout  time.Duration   `yaml:"session_timeout" json:"session_timeout" ini:"session_timeout"`    // 会话超时(建议15-30秒)
	BasePath        string          `yaml:"base_path" json:"base_path" ini:"base_path"`                      // 基础路径(如"/services/prod")
	Auth            ACL             `yaml:"auth" json:"auth" ini:"auth"`                                     // 认证信息
	EnableEphemeral bool            `yaml:"enable_ephemeral" json:"enable_ephemeral" ini:"enable_ephemeral"` // 是否自动恢复临时节点
	Retries         backoff.Backoff `yaml:"retries" json:"retries" ini:"retries"`                            // 重试配置
}

Config Zookeeper客户端配置

func (*Config) NewClient

func (c *Config) NewClient() (*Client, error)

NewClient 创建并返回一个新的Zookeeper客户端

Jump to

Keyboard shortcuts

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