From 0c83460f04d66940fd9a38886ec38700213dae54 Mon Sep 17 00:00:00 2001 From: IcePigZDB Date: Mon, 13 Dec 2021 02:58:09 +0000 Subject: [PATCH] store/helper: add GetStoreRegionsInfo by store id ref: #28330 Signed-off-by: IcePigZDB --- store/helper/helper.go | 7 +++++++ util/pdapi/const.go | 17 +++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/store/helper/helper.go b/store/helper/helper.go index 125052d10cd75..5f54f96b06fcf 100644 --- a/store/helper/helper.go +++ b/store/helper/helper.go @@ -733,6 +733,13 @@ func (h *Helper) GetRegionsInfo() (*RegionsInfo, error) { return ®ionsInfo, 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, ®ionsInfo) + return ®ionsInfo, 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 diff --git a/util/pdapi/const.go b/util/pdapi/const.go index 0ce75f5d5a6a0..d2964cdb8d50a 100644 --- a/util/pdapi/const.go +++ b/util/pdapi/const.go @@ -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" )