Documentation ¶
Index ¶
- Variables
- func NewServiceScript(config interface{}) (res map[string]interface{}, err error)
- type Config
- type IService
- type Info
- type NodeEvent
- type NodeInfo
- type Service
- func (this_ *Service) Close()
- func (this_ *Service) Create(path string, data string) (err error)
- func (this_ *Service) CreateEphemeral(path string, data string) (err error)
- func (this_ *Service) CreateEphemeralIfNotExists(path string, data string) (err error)
- func (this_ *Service) CreateIfNotExists(path string, data string) (err error)
- func (this_ *Service) Delete(path string) (err error)
- func (this_ *Service) Exists(path string) (isExist bool, err error)
- func (this_ *Service) Get(path string) (data string, err error)
- func (this_ *Service) GetChildren(path string) (children []string, err error)
- func (this_ *Service) GetConn() *zk.Conn
- func (this_ *Service) GetInfo(path string) (info *NodeInfo, err error)
- func (this_ *Service) GetServers() []string
- func (this_ *Service) Info() (info *Info, err error)
- func (this_ *Service) Set(path string, data string) (err error)
- func (this_ *Service) Stat(path string) (info *StatInfo, err error)
- func (this_ *Service) WatchChildren(path string, listen func(data *WatchChildrenListenData) (finish bool)) (err error)
- type StatInfo
- type WatchChildrenListenData
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 ¶
func NewServiceScript ¶ added in v0.5.7
Types ¶
type Config ¶
type Config struct { Address string `json:"address" yaml:"address"` Username string `json:"username,omitempty" yaml:"username,omitempty"` Password string `json:"password,omitempty" yaml:"password,omitempty"` SessionTimeout int `json:"sessionTimeout,omitempty" yaml:"sessionTimeout,omitempty"` // 会话超时 单位 毫秒 ConnectionTimeout int `json:"connectionTimeout,omitempty" yaml:"connectionTimeout,omitempty"` // 客户端连接超时 单位 毫秒 SSHClient *ssh.Client `json:"-"` }
type IService ¶ added in v0.0.5
type IService interface { // Close 关闭 客户端 Close() // GetConn 获取 zk Conn GetConn() *zk.Conn // Info 查看 zk 相关信息 Info() (info *Info, err error) // Create 创建 永久 节点 Create(path string, value string) (err error) // CreateIfNotExists 如果不存在 则创建 永久 节点 创建时候如果已存在不报错 如果 父节点不存在 则先创建父节点 CreateIfNotExists(path string, value string) (err error) // CreateEphemeral 创建 临时 节点 CreateEphemeral(path string, value string) (err error) // CreateEphemeralIfNotExists 如果不存在 则创建 临时 节点 创建时候如果已存在不报错 如果 父节点不存在 则先创建父节点 CreateEphemeralIfNotExists(path string, value string) (err error) // Exists 查看节点是否存在 Exists(path string) (isExist bool, err error) // Set 设置 节点 值 Set(path string, value string) (err error) // Get 查看 节点 数据 Get(path string) (value string, err error) // GetInfo 查看 节点 信息 GetInfo(path string) (info *NodeInfo, err error) // Stat 节点 状态 Stat(path string) (info *StatInfo, err error) // GetChildren 查询 子节点 GetChildren(path string) (children []string, err error) // Delete 删除节点 如果 包含子节点 则先删除所有子节点 Delete(path string) (err error) // WatchChildren 监听 子节点 只监听当前节点下的子节点 NodeEventError 监听异常 NodeEventStopped zk客户端关闭 NodeEventAdded 节点新增 NodeEventDeleted 节点删除 NodeEventNodeNotFound 节点不存在 WatchChildren(path string, listen func(data *WatchChildrenListenData) (finish bool)) (err error) }
type Service ¶ added in v0.0.5
type Service struct { *Config // contains filtered or unexported fields }
Service 注册处理器在线信息等
func (*Service) CreateEphemeral ¶ added in v0.5.7
func (*Service) CreateEphemeralIfNotExists ¶ added in v0.5.7
func (*Service) CreateIfNotExists ¶ added in v0.0.5
CreateIfNotExists 一层层检查,如果不存在则创建
func (*Service) GetChildren ¶ added in v0.0.5
GetChildren 查询子节点
func (*Service) GetServers ¶ added in v0.0.5
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 ¶
Click to show internal directories.
Click to hide internal directories.