本文整理匯總了Golang中github.com/QubitProducts/bamboo/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk.Conn.Create方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.Create方法的具體用法?Golang Conn.Create怎麽用?Golang Conn.Create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/QubitProducts/bamboo/Godeps/_workspace/src/github.com/samuel/go-zookeeper/zk.Conn
的用法示例。
在下文中一共展示了Conn.Create方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: loadToZK
func loadToZK(conn *zk.Conn, data [][2]string) {
for _, entry := range data {
k := entry[0]
v := entry[1]
_, err := conn.Create(k, []byte(v), 0, defaultACL())
orPanic(err)
}
}
示例2: Create
/*
Read ZK ACL:
http://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html#sc_ACLPermissions
*/
func Create(conn *zk.Conn, zkConf conf.Zookeeper, appId string, domainValue string) (string, error) {
path := concatPath(zkConf.Path, validateAppId(appId))
resPath, err := conn.Create(path, []byte(domainValue), 0, defaultACL())
if err != nil {
return "", err
}
return resPath, nil
}
示例3: ensurePathExists
func ensurePathExists(conn *zk.Conn, path string) error {
pathExists, _, _ := conn.Exists(path)
if pathExists {
return nil
}
_, err := conn.Create(path, []byte{}, 0, defaultACL())
if err != nil {
return err
}
return nil
}
示例4: zkCreateNodes
func zkCreateNodes(path string, nodes []string, c *zk.Conn) error {
if len(nodes) > 0 {
// strings.Split will return empty-strings for leading split chars, lets skip over these.
if len(nodes[0]) == 0 {
return zkCreateNodes(path, nodes[1:], c)
}
fqPath := path + "/" + nodes[0]
log.Printf("Creating path: %v", fqPath)
exists, _, err := c.Exists(fqPath)
if err != nil {
return err
}
if !exists {
_, err := c.Create(fqPath, []byte{}, 0, zk.WorldACL(zk.PermAll))
if err != nil {
return err
}
}
return zkCreateNodes(fqPath, nodes[1:], c)
}
return nil
}