本文整理匯總了Golang中github.com/ianwoolf/zkClient/util.ZH類的典型用法代碼示例。如果您正苦於以下問題:Golang ZH類的具體用法?Golang ZH怎麽用?Golang ZH使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ZH類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Get
func Get(zh *u.ZH, path string) (content string, stat zk.Stat, err error) {
var read []byte
read, stat, err = zh.Get(path)
if err == nil {
content = string(read)
}
return
}
示例2: DelChildNode
func DelChildNode(zh *u.ZH, path string) (err error) {
var childNodes []string
var stat zk.Stat
childNodes, err = zh.Children(path)
if err != nil {
fmt.Println("get node %s clindren error: %s", path, err.Error())
return
}
fmt.Println("begin to del node:", childNodes)
for _, node := range childNodes {
nodeToDel := fmt.Sprintf("%s/%s", path, node)
_, stat, err = zh.Get(nodeToDel)
if err != nil {
fmt.Println("get zk node fail:", nodeToDel, err.Error())
return
} else {
fmt.Println("begin to del node:", nodeToDel)
}
err = zh.Delete(nodeToDel, int32(stat.Version()))
if err != nil {
fmt.Printf("del node %s error: %s", nodeToDel, err.Error())
continue
}
}
return
}
示例3: WatchChildren
func WatchChildren(zh *u.ZH, path string) (children []string, event <-chan zk.Event, err error) {
children, event, err = zh.ChildrenW(path)
return
}
示例4: WatchExist
func WatchExist(zh *u.ZH, path string) (ok bool, event <-chan zk.Event) {
ok, event = zh.ExistsW(path)
return
}
示例5: Create
func Create(zh *u.ZH, path string, data []byte, flags int32) (string, error) {
return zh.Create(path, data, flags)
}
示例6: GetLock
func GetLock(zh *u.ZH, path string) *zk.Lock {
return zh.NewLock(path)
}
示例7: Set
func Set(zh *u.ZH, path string, data []byte, version int32) (stat zk.Stat, err error) {
stat, err = zh.Set(path, data, version)
return
}
示例8: Children
func Children(zh *u.ZH, path string) (paths []string, err error) {
paths, err = zh.Children(path)
return
}