(client *Client, tableName string)
| 33 | } |
| 34 | |
| 35 | func GetTablePartitions(client *Client, tableName string) (partitions []PartitionStruct, err error) { |
| 36 | resp, err := client.Meta.QueryConfig(tableName) |
| 37 | if err != nil { |
| 38 | return partitions, err |
| 39 | } |
| 40 | for _, partition := range resp.Partitions { |
| 41 | p := PartitionStruct{} |
| 42 | p.Pidx = partition.Pid.PartitionIndex |
| 43 | |
| 44 | primary := client.Nodes.MustGetReplica(partition.Primary.GetAddress()) |
| 45 | p.PrimaryAddr = primary.CombinedAddr() |
| 46 | |
| 47 | var secondaries []string |
| 48 | for _, sec := range partition.Secondaries { |
| 49 | secNode := client.Nodes.MustGetReplica(sec.GetAddress()) |
| 50 | secondaries = append(secondaries, secNode.CombinedAddr()) |
| 51 | } |
| 52 | p.SecondariesAddr = strings.Join(secondaries, ",") |
| 53 | |
| 54 | partitions = append(partitions, p) |
| 55 | } |
| 56 | |
| 57 | return partitions, nil |
| 58 | } |
| 59 | |
| 60 | func ShowPartitionCount(client *Client, tableName string) error { |
| 61 | resp, err := client.Meta.QueryConfig(tableName) |
no test coverage detected