Documentation ¶
Index ¶
- Constants
- Variables
- type ChildrenChange
- type Event
- type EventChildrenNodeChangeType
- type EventCurrentNodeChangeType
- type EventType
- type NodeChange
- type NodeDetail
- type Option
- type WatchChildrenResponse
- type WatchNodeResponse
- type ZookeeperProxy
- func (z *ZookeeperProxy) Close() error
- func (z *ZookeeperProxy) CreateNode(path string, flag int32, data string) (string, error)
- func (z *ZookeeperProxy) CreateNodeParent(path string, flags int32, data string) (string, error)
- func (z *ZookeeperProxy) CreateNodeWithAcls(path string, flag int32, acls []zk.ACL, data string) (string, error)
- func (z *ZookeeperProxy) Delete(path string) error
- func (z *ZookeeperProxy) Exist(path string) (bool, error)
- func (z *ZookeeperProxy) GetChildren(path string) ([]string, error)
- func (z *ZookeeperProxy) GetConnState() string
- func (z *ZookeeperProxy) GetData(path string) (string, error)
- func (z *ZookeeperProxy) GetSessionId() int64
- func (z *ZookeeperProxy) SetData(path string, s string) error
- func (z *ZookeeperProxy) StartLi() (<-chan Event, error)
- func (z *ZookeeperProxy) WatchChildren(path string, listener func(respChan <-chan *WatchChildrenResponse))
- func (z *ZookeeperProxy) WatchNode(path string, listener func(respChan <-chan *WatchNodeResponse))
Constants ¶
View Source
const ( PERSISTENT = iota // 持久化节点 EPHEMERAL // 临时节点, 客户端session超时这类节点就会被自动删除 PERSISTENT_SEQUENTIAL // 顺序自动编号持久化节点,这种节点会根据当前已存在的节点数自动加 1 EPHEMERAL_SEQUENTIAL // 临时自动编号节点 )
Variables ¶
View Source
var ( EventChildrenNodeChangeNames = map[EventChildrenNodeChangeType]string{ EventChildrenNodeDelete: "EventChildrenNodeDelete", EventChildrenNodeIncrease: "EventChildrenNodeIncrease", } )
View Source
var ( EventCurrntNodeChangeNames = map[EventCurrentNodeChangeType]string{ EventNodeDelete: "EventNodeDelete", EventNodeDataChange: "EventNodeDataChange", } )
Functions ¶
This section is empty.
Types ¶
type ChildrenChange ¶
type ChildrenChange struct { OperateType EventChildrenNodeChangeType // 监控到子节点的操作类型: 目前只支持监控子节点的 增加 删除 Path string // 节点路径 }
type EventChildrenNodeChangeType ¶
type EventChildrenNodeChangeType int32
const ( EventChildrenNodeDelete EventChildrenNodeChangeType = iota EventChildrenNodeIncrease )
func (EventChildrenNodeChangeType) String ¶
func (e EventChildrenNodeChangeType) String() string
type EventCurrentNodeChangeType ¶
type EventCurrentNodeChangeType int32
const ( EventNodeDelete EventCurrentNodeChangeType = iota EventNodeDataChange )
func (EventCurrentNodeChangeType) String ¶
func (t EventCurrentNodeChangeType) String() string
type NodeChange ¶
type NodeChange struct { OperateType EventCurrentNodeChangeType // 监控到的子节点的操作类型 OldData string // 节点改变前的值 NewData string // 节点改变后的值 Path string // 节点路径 }
type NodeDetail ¶
type WatchChildrenResponse ¶
type WatchChildrenResponse struct { ChildrenChangeInfo []*ChildrenChange Err error }
type WatchNodeResponse ¶
type WatchNodeResponse struct { NodeChangeInfo *NodeChange Err error }
type ZookeeperProxy ¶
func New ¶
func New(opt *Option) (*ZookeeperProxy, error)
func (*ZookeeperProxy) Close ¶
func (z *ZookeeperProxy) Close() error
func (*ZookeeperProxy) CreateNode ¶
创建节点(拥有所有权限)
func (*ZookeeperProxy) CreateNodeParent ¶
创建节点(包含父节点): 若要创建节点的父节点不存在,则把 父节点 和 需求节点都创建出来。 注: 所有新建的父节点的flags 为0 , 需求节点的flags为传入的 flags
func (*ZookeeperProxy) CreateNodeWithAcls ¶
func (z *ZookeeperProxy) CreateNodeWithAcls(path string, flag int32, acls []zk.ACL, data string) (string, error)
创建节点(自定义节点权限)
func (*ZookeeperProxy) GetChildren ¶
func (z *ZookeeperProxy) GetChildren(path string) ([]string, error)
获取子节点列表
func (*ZookeeperProxy) GetConnState ¶
func (z *ZookeeperProxy) GetConnState() string
获取zookeeper当前的连接状态
func (*ZookeeperProxy) GetData ¶
func (z *ZookeeperProxy) GetData(path string) (string, error)
获取节点值
func (*ZookeeperProxy) GetSessionId ¶
func (z *ZookeeperProxy) GetSessionId() int64
获取当前连接的sessionId
func (*ZookeeperProxy) SetData ¶
func (z *ZookeeperProxy) SetData(path string, s string) error
设置节点值
func (*ZookeeperProxy) WatchChildren ¶
func (z *ZookeeperProxy) WatchChildren(path string, listener func(respChan <-chan *WatchChildrenResponse))
监听子节点 TODO: 目前只支持对子节点进行 增加 或 删除的监控, 不支持对 子节点值改变 的监控
func (*ZookeeperProxy) WatchNode ¶
func (z *ZookeeperProxy) WatchNode(path string, listener func(respChan <-chan *WatchNodeResponse))
对节点监听
Click to show internal directories.
Click to hide internal directories.