-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: show more region info in api #589
Conversation
Please fix the conflict first. |
pdctl/command/region_command.go
Outdated
return | ||
} | ||
region, leader, err := client.GetRegion(context.Background(), key) | ||
prefix := fmt.Sprintf(regionKeyPrefix, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any needs of using url.PathEscape()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function PathEscape
is new add in go 1.8. It is enough to deal with the key firstly with the protobuf format.
pdctl/command/region_command.go
Outdated
regionPrefix = "pd/api/v1/region/%s" | ||
regionsPrefix = "pd/api/v1/regions" | ||
regionIDPrefix = "pd/api/v1/region/id/%s" | ||
regionKeyPrefix = "pd/api/v1/region/key/%s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix should not contain %s
here, you can format whole key explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or use string add directly
server/cluster.go
Outdated
// GetRegionInfoByKey gets regionInfo by region key from cluster. | ||
func (c *RaftCluster) GetRegionInfoByKey(regionKey []byte) *RegionInfo { | ||
region := c.cachedCluster.searchRegion(regionKey) | ||
if region == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can return region here directly, no need checking nil here
server/cluster.go
Outdated
// GetRegionInfoByID gets regionInfo by regionID from cluster. | ||
func (c *RaftCluster) GetRegionInfoByID(regionID uint64) *RegionInfo { | ||
region := c.cachedCluster.getRegion(regionID) | ||
if region == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
what does the pd-ctl output now? |
like
|
I think we should support protobuf string output format for start and end key later. LGTM |
LGTM |
close #583
PTAL @disksing @siddontang @andelf