本文整理匯總了Golang中github.com/youtube/vitess/go/zk.CreateOrUpdate函數的典型用法代碼示例。如果您正苦於以下問題:Golang CreateOrUpdate函數的具體用法?Golang CreateOrUpdate怎麽用?Golang CreateOrUpdate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CreateOrUpdate函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WriteAddrs
// WriteAddrs writes a ZknsAddres record to a path in Zookeeper.
func WriteAddrs(zconn zk.Conn, zkPath string, addrs *ZknsAddrs) error {
if !(addrs.IsValidA() || addrs.IsValidCNAME() || addrs.IsValidSRV()) {
return fmt.Errorf("invalid addrs: %v", zkPath)
}
data := toJson(addrs)
_, err := zk.CreateOrUpdate(zconn, zkPath, data, 0, zookeeper.WorldACL(zk.PERM_FILE), true)
return err
}
示例2: writeAddrs
func writeAddrs(zconn zk.Conn, zkPath string, addrs *LegacyZknsAddrs) error {
data, err := json.MarshalIndent(addrs, "", " ")
if err != nil {
return err
}
_, err = zk.CreateOrUpdate(zconn, zkPath, string(data), 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
return err
}
示例3: SaveVSchema
// SaveVSchema saves the JSON vschema into the topo.
func (zkts *Server) SaveVSchema(ctx context.Context, vschema string) error {
_, err := planbuilder.NewSchema([]byte(vschema))
if err != nil {
return err
}
_, err = zk.CreateOrUpdate(zkts.zconn, globalVSchemaPath, vschema, 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
return err
}
示例4: SaveVSchema
// SaveVSchema saves the vschema into the topo.
func (zkts *Server) SaveVSchema(ctx context.Context, keyspace string, vschema *vschemapb.Keyspace) error {
data, err := json.MarshalIndent(vschema, "", " ")
if err != nil {
return err
}
vschemaPath := path.Join(GlobalKeyspacesPath, keyspace, vschemaPath)
_, err = zk.CreateOrUpdate(zkts.zconn, vschemaPath, string(data), 0, zookeeper.WorldACL(zookeeper.PermAll), true)
return convertError(err)
}
示例5: SaveVSchema
// SaveVSchema saves the JSON vschema into the topo.
func (zkts *Server) SaveVSchema(ctx context.Context, keyspace, vschema string) error {
err := vindexes.ValidateVSchema([]byte(vschema))
if err != nil {
return err
}
vschemaPath := path.Join(GlobalKeyspacesPath, keyspace, vschemaPath)
_, err = zk.CreateOrUpdate(zkts.zconn, vschemaPath, vschema, 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
return err
}
示例6: writeAddrs
func writeAddrs(zconn zk.Conn, zkPath string, addrs *LegacyZknsAddrs) error {
data := jscfg.ToJSON(addrs)
_, err := zk.CreateOrUpdate(zconn, zkPath, data, 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
return err
}
示例7: WriteAddr
func WriteAddr(zconn zk.Conn, zkPath string, addr *zkns.ZknsAddr) error {
data := jscfg.ToJson(addr)
_, err := zk.CreateOrUpdate(zconn, zkPath, data, 0, zookeeper.WorldACL(zookeeper.PERM_ALL), true)
return err
}