本文整理匯總了Golang中github.com/youtube/vitess/go/zk.Conn.Delete方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.Delete方法的具體用法?Golang Conn.Delete怎麽用?Golang Conn.Delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/youtube/vitess/go/zk.Conn
的用法示例。
在下文中一共展示了Conn.Delete方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: exportVtnsToZkns
func (wr *Wrangler) exportVtnsToZkns(ctx context.Context, zconn zk.Conn, vtnsAddrPath, zknsAddrPath string) ([]string, error) {
zknsPaths := make([]string, 0, 32)
parts := strings.Split(vtnsAddrPath, "/")
if len(parts) != 8 && len(parts) != 9 {
return nil, fmt.Errorf("Invalid leaf zk path: %v", vtnsAddrPath)
}
cell := parts[2]
keyspace := parts[5]
shard := parts[6]
tabletType := topo.TabletType(parts[7])
if tabletType == "action" || tabletType == "actionlog" {
return nil, nil
}
addrs, _, err := wr.ts.GetEndPoints(ctx, cell, keyspace, shard, tabletType)
if err != nil {
return nil, err
}
// Write the individual endpoints and compute the SRV entries.
vtoccAddrs := LegacyZknsAddrs{make([]string, 0, 8)}
defaultAddrs := LegacyZknsAddrs{make([]string, 0, 8)}
for i, entry := range addrs.Entries {
zknsAddrPath := fmt.Sprintf("%v/%v", zknsAddrPath, i)
zknsPaths = append(zknsPaths, zknsAddrPath)
zknsAddr := zkns.ZknsAddr{
Host: entry.Host,
PortMap: entry.PortMap,
}
err := writeAddr(zconn, zknsAddrPath, &zknsAddr)
if err != nil {
return nil, err
}
defaultAddrs.Endpoints = append(defaultAddrs.Endpoints, zknsAddrPath)
vtoccAddrs.Endpoints = append(vtoccAddrs.Endpoints, zknsAddrPath+":vt")
}
// Prune any zkns entries that are no longer referenced by the
// shard graph.
deleteIdx := len(addrs.Entries)
for {
zknsStaleAddrPath := fmt.Sprintf("%v/%v", zknsAddrPath, deleteIdx)
// A "delete" is a write of sorts - just communicate up that nothing
// needs to be done to this node.
zknsPaths = append(zknsPaths, zknsStaleAddrPath)
err := zconn.Delete(zknsStaleAddrPath, -1)
if zookeeper.IsError(err, zookeeper.ZNONODE) {
break
}
if err != nil {
return nil, err
}
deleteIdx++
}
// Write the VDNS entries for both vtocc and mysql
vtoccVdnsPath := fmt.Sprintf("%v/vt.vdns", zknsAddrPath)
zknsPaths = append(zknsPaths, vtoccVdnsPath)
if err = writeAddrs(zconn, vtoccVdnsPath, &vtoccAddrs); err != nil {
return nil, err
}
defaultVdnsPath := fmt.Sprintf("%v.vdns", zknsAddrPath)
zknsPaths = append(zknsPaths, defaultVdnsPath)
if err = writeAddrs(zconn, defaultVdnsPath, &defaultAddrs); err != nil {
return nil, err
}
return zknsPaths, nil
}