Skip to content

Commit

Permalink
store/helper: add GetStoreRegionsInfo by store id
Browse files Browse the repository at this point in the history
ref: pingcap#28330

Signed-off-by: IcePigZDB <icepigzdb@gmail.com>
  • Loading branch information
IcePigZDB committed Dec 13, 2021
1 parent 7555536 commit 0c83460
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
7 changes: 7 additions & 0 deletions store/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,13 @@ func (h *Helper) GetRegionsInfo() (*RegionsInfo, error) {
return &regionsInfo, err
}

// GetStoreRegionsInfo gets the region in given store.
func (h *Helper) GetStoreRegionsInfo(storeID uint64) (*RegionsInfo, error) {
var regionsInfo RegionsInfo
err := h.requestPD("GET", pdapi.StoreRegions+strconv.FormatUint(storeID, 10), nil, &regionsInfo)
return &regionsInfo, err
}

// GetRegionInfoByID gets the region information of the region ID by using PD's api.
func (h *Helper) GetRegionInfoByID(regionID uint64) (*RegionInfo, error) {
var regionInfo RegionInfo
Expand Down
17 changes: 9 additions & 8 deletions util/pdapi/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ package pdapi

// The following constants are the APIs of PD server.
const (
HotRead = "/pd/api/v1/hotspot/regions/read"
HotWrite = "/pd/api/v1/hotspot/regions/write"
HotHistory = "/pd/api/v1/hotspot/regions/history"
Regions = "/pd/api/v1/regions"
RegionByID = "/pd/api/v1/region/id/"
Stores = "/pd/api/v1/stores"
Status = "/pd/api/v1/status"
Config = "/pd/api/v1/config"
HotRead = "/pd/api/v1/hotspot/regions/read"
HotWrite = "/pd/api/v1/hotspot/regions/write"
HotHistory = "/pd/api/v1/hotspot/regions/history"
Regions = "/pd/api/v1/regions"
RegionByID = "/pd/api/v1/region/id/"
StoreRegions = "/pd/api/v1/regions/store/"
Stores = "/pd/api/v1/stores"
Status = "/pd/api/v1/status"
Config = "/pd/api/v1/config"
)

0 comments on commit 0c83460

Please sign in to comment.