本文整理汇总了Golang中github.com/youtube/vitess/go/rpcplus.Client.Call方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.Call方法的具体用法?Golang Client.Call怎么用?Golang Client.Call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/rpcplus.Client
的用法示例。
在下文中一共展示了Client.Call方法的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))
}
}
}