本文整理匯總了Golang中github.com/youtube/vitess/go/rpcplus.Client類的典型用法代碼示例。如果您正苦於以下問題:Golang Client類的具體用法?Golang Client怎麽用?Golang Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Client類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getSrvKeyspace
func getSrvKeyspace(rpcClient *rpcplus.Client, cell, keyspace string, verbose bool) {
req := &topo.GetSrvKeyspaceArgs{
Cell: cell,
Keyspace: keyspace,
}
reply := &topo.SrvKeyspace{}
if err := rpcClient.Call("TopoReader.GetSrvKeyspace", req, reply); err != nil {
log.Fatalf("TopoReader.GetSrvKeyspace error: %v", err)
}
if verbose {
tabletTypes := make([]string, 0, len(reply.Partitions))
for t, _ := range reply.Partitions {
tabletTypes = append(tabletTypes, string(t))
}
sort.Strings(tabletTypes)
for _, t := range tabletTypes {
println(fmt.Sprintf("Partitions[%v] =", t))
for i, s := range reply.Partitions[topo.TabletType(t)].Shards {
println(fmt.Sprintf(" Shards[%v]=%v", i, s.KeyRange.String()))
}
}
for i, s := range reply.Shards {
println(fmt.Sprintf("Shards[%v]=%v", i, s.KeyRange.String()))
}
for i, t := range reply.TabletTypes {
println(fmt.Sprintf("TabletTypes[%v] = %v", i, t))
}
}
}
示例2: get
func get(rpcClient *rpcplus.Client, path string, verbose bool) {
// it's a get
zkPath := &zk.ZkPath{Path: path}
zkNode := &zk.ZkNode{}
if err := rpcClient.Call("ZkReader.Get", zkPath, zkNode); err != nil {
log.Fatalf("ZkReader.Get error: %v", err)
}
if verbose {
println(fmt.Sprintf("%v = %v (NumChildren=%v, Version=%v, Cached=%v, Stale=%v)", zkNode.Path, zkNode.Data, zkNode.Stat.NumChildren(), zkNode.Stat.Version(), zkNode.Cached, zkNode.Stale))
}
}
示例3: getSrvKeyspaceNames
func getSrvKeyspaceNames(rpcClient *rpcplus.Client, cell string, verbose bool) {
req := &topo.GetSrvKeyspaceNamesArgs{
Cell: cell,
}
reply := &topo.SrvKeyspaceNames{}
if err := rpcClient.Call("TopoReader.GetSrvKeyspaceNames", req, reply); err != nil {
log.Fatalf("TopoReader.GetSrvKeyspaceNames error: %v", err)
}
if verbose {
for i, entry := range reply.Entries {
println(fmt.Sprintf("KeyspaceNames[%v] = %v", i, entry))
}
}
}
示例4: getv
func getv(rpcClient *rpcplus.Client, paths []string, verbose bool) {
zkPathV := &zk.ZkPathV{Paths: make([]string, len(paths))}
for i, v := range paths {
zkPathV.Paths[i] = v
}
zkNodeV := &zk.ZkNodeV{}
if err := rpcClient.Call("ZkReader.GetV", zkPathV, zkNodeV); err != nil {
log.Fatalf("ZkReader.GetV error: %v", err)
}
if verbose {
for i, zkNode := range zkNodeV.Nodes {
println(fmt.Sprintf("[%v] %v = %v (NumChildren=%v, Version=%v, Cached=%v, Stale=%v)", i, zkNode.Path, zkNode.Data, zkNode.Stat.NumChildren(), zkNode.Stat.Version(), zkNode.Cached, zkNode.Stale))
}
}
}
示例5: getEndPoints
func getEndPoints(rpcClient *rpcplus.Client, cell, keyspace, shard, tabletType string, verbose bool) {
req := &topo.GetEndPointsArgs{
Cell: cell,
Keyspace: keyspace,
Shard: shard,
TabletType: topo.TabletType(tabletType),
}
reply := &topo.EndPoints{}
if err := rpcClient.Call("TopoReader.GetEndPoints", req, reply); err != nil {
log.Fatalf("TopoReader.GetEndPoints error: %v", err)
}
if verbose {
for i, e := range reply.Entries {
println(fmt.Sprintf("Entries[%v] = %v %v", i, e.Uid, e.Host))
}
}
}
示例6: children
func children(rpcClient *rpcplus.Client, paths []string, verbose bool) {
for _, v := range paths {
zkPath := &zk.ZkPath{Path: v}
zkNode := &zk.ZkNode{}
if err := rpcClient.Call("ZkReader.Children", zkPath, zkNode); err != nil {
log.Fatalf("ZkReader.Children error: %v", err)
}
if verbose {
println(fmt.Sprintf("Path = %v", zkNode.Path))
for i, child := range zkNode.Children {
println(fmt.Sprintf("Child[%v] = %v", i, child))
}
println(fmt.Sprintf("NumChildren = %v", zkNode.Stat.NumChildren()))
println(fmt.Sprintf("CVersion = %v", zkNode.Stat.CVersion()))
println(fmt.Sprintf("Cached = %v", zkNode.Cached))
println(fmt.Sprintf("Stale = %v", zkNode.Stale))
}
}
}