zookeeper

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NodeEventAdded = newNodeEvent("node event node added")
View Source
var NodeEventDeleted = newNodeEvent("node event node deleted")
View Source
var NodeEventError = newNodeEvent("node event node listen error")
View Source
var NodeEventNodeNotFound = newNodeEvent("node event node not found")
View Source
var NodeEventStopped = newNodeEvent("node event zk is stopped")
View Source
var ZKLogger zk.Logger = &defaultLogger{}

Functions

This section is empty.

Types

type Config

type Config struct {
	Address  string `json:"address"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

type IService added in v0.0.5

type IService interface {
	Stop()
	Create(path string, data []byte, mode int32) (err error)
	Info() (info *Info, err error)
	Set(path string, data []byte) (err error)
	CreateIfNotExists(path string, data []byte) (err error)
	Exists(path string) (isExist bool, err error)
	Get(path string) (info *NodeInfo, err error)
	Stat(path string) (info *StatInfo, err error)
	GetChildren(path string) (children []string, err error)
	Delete(path string) (err error)
	WatchChildren(path string, listen func(data *WatchChildrenListenData) (finish bool)) (err error)
}

func New

func New(config Config) (IService, error)

New 创建zookeeper客户端

type Info

type Info struct {
	Server    string   `json:"server"`
	SessionID int64    `json:"sessionID"`
	State     zk.State `json:"state"`
}

type NodeEvent

type NodeEvent string

type NodeInfo

type NodeInfo struct {
	Path string    `json:"path"`
	Data string    `json:"data"`
	Stat *StatInfo `json:"stat"`
}

type Service added in v0.0.5

type Service struct {
	Config
	// contains filtered or unexported fields
}

Service 注册处理器在线信息等

func (*Service) Create added in v0.0.5

func (this_ *Service) Create(path string, data []byte, mode int32) (err error)

Create 创建节点

func (*Service) CreateIfNotExists added in v0.0.5

func (this_ *Service) CreateIfNotExists(path string, data []byte) (err error)

CreateIfNotExists 一层层检查,如果不存在则创建

func (*Service) Delete added in v0.0.5

func (this_ *Service) Delete(path string) (err error)

Delete 删除节点 如果有子节点,则子节点一同删除

func (*Service) Exists added in v0.0.5

func (this_ *Service) Exists(path string) (isExist bool, err error)

Exists 判断节点是否存在

func (*Service) Get added in v0.0.5

func (this_ *Service) Get(path string) (info *NodeInfo, err error)

Get 获取节点信息

func (*Service) GetChildren added in v0.0.5

func (this_ *Service) GetChildren(path string) (children []string, err error)

GetChildren 查询子节点

func (*Service) GetConn added in v0.0.5

func (this_ *Service) GetConn() *zk.Conn

func (*Service) GetServers added in v0.0.5

func (this_ *Service) GetServers() []string

func (*Service) Info added in v0.0.5

func (this_ *Service) Info() (info *Info, err error)

Info ZK信息

func (*Service) Set added in v0.0.5

func (this_ *Service) Set(path string, data []byte) (err error)

Set 修改节点数据

func (*Service) Stat added in v0.0.5

func (this_ *Service) Stat(path string) (info *StatInfo, err error)

Stat 获取节点状态

func (*Service) Stop added in v0.0.5

func (this_ *Service) Stop()

func (*Service) WatchChildren added in v0.0.5

func (this_ *Service) WatchChildren(path string, listen func(data *WatchChildrenListenData) (finish bool)) (err error)

WatchChildren 监听子节点 子节点 新增 删除

type StatInfo

type StatInfo struct {
	Czxid          int64 `json:"czxid,omitempty"`
	Mzxid          int64 `json:"mzxid,omitempty"`
	Ctime          int64 `json:"ctime,omitempty"`
	Mtime          int64 `json:"mtime,omitempty"`
	Version        int32 `json:"version,omitempty"`
	Cversion       int32 `json:"cversion,omitempty"`
	Aversion       int32 `json:"aversion,omitempty"`
	EphemeralOwner int64 `json:"ephemeralOwner,omitempty"`
	DataLength     int32 `json:"dataLength,omitempty"`
	NumChildren    int32 `json:"numChildren,omitempty"`
	Pzxid          int64 `json:"pzxid,omitempty"`
}

func StatToInfo

func StatToInfo(stat *zk.Stat) (info *StatInfo)

type WatchChildrenListenData

type WatchChildrenListenData struct {
	Path  string
	Event *NodeEvent
	Child string
	Err   error
}

Jump to

Keyboard shortcuts

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