From a98d738338a6e9906c98232d202713af8aaa5041 Mon Sep 17 00:00:00 2001 From: JmPotato Date: Thu, 30 Nov 2023 15:56:46 +0800 Subject: [PATCH] Address the comments Signed-off-by: JmPotato --- client/http/client.go | 2 ++ client/http/codec.go | 2 +- server/api/stats.go | 5 +++-- server/api/store.go | 16 ++++++++-------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/client/http/client.go b/client/http/client.go index 21b7bea20db..36355a90d19 100644 --- a/client/http/client.go +++ b/client/http/client.go @@ -358,6 +358,7 @@ func (c *client) GetRegionsByStoreID(ctx context.Context, storeID uint64) (*Regi } // GetRegionsReplicatedStateByKeyRange gets the regions replicated state info by key range. +// The keys in the key range should be encoded in the hex bytes format (without encoding to the UTF-8 bytes). func (c *client) GetRegionsReplicatedStateByKeyRange(ctx context.Context, keyRange *KeyRange) (string, error) { var state string err := c.requestWithRetry(ctx, @@ -411,6 +412,7 @@ func (c *client) GetHistoryHotRegions(ctx context.Context, req *HistoryHotRegion } // GetRegionStatusByKeyRange gets the region status by key range. +// If the `onlyCount` flag is true, the result will only include the count of regions. // The keys in the key range should be encoded in the UTF-8 bytes format. func (c *client) GetRegionStatusByKeyRange(ctx context.Context, keyRange *KeyRange, onlyCount bool) (*RegionStats, error) { var regionStats RegionStats diff --git a/client/http/codec.go b/client/http/codec.go index cac1a89fd87..26be64b4f28 100644 --- a/client/http/codec.go +++ b/client/http/codec.go @@ -100,7 +100,7 @@ func decodeBytes(b []byte) ([]byte, error) { return buf, nil } -// keyToKeyHexStr converts a raw key to a hex string after encoding. +// rawKeyToKeyHexStr converts a raw key to a hex string after encoding. func rawKeyToKeyHexStr(key []byte) string { if len(key) == 0 { return "" diff --git a/server/api/stats.go b/server/api/stats.go index 1798597b6cc..915d33ddfdf 100644 --- a/server/api/stats.go +++ b/server/api/stats.go @@ -36,8 +36,9 @@ func newStatsHandler(svr *server.Server, rd *render.Render) *statsHandler { // @Tags stats // @Summary Get region statistics of a specified range. -// @Param start_key query string true "Start key" -// @Param end_key query string true "End key" +// @Param start_key query string true "Start key" +// @Param end_key query string true "End key" +// @Param count query bool false "Whether only count the number of regions" // @Produce json // @Success 200 {object} statistics.RegionStats // @Router /stats/region [get] diff --git a/server/api/store.go b/server/api/store.go index a44850d35cc..8537cd45c5b 100644 --- a/server/api/store.go +++ b/server/api/store.go @@ -172,14 +172,14 @@ func newStoreHandler(handler *server.Handler, rd *render.Render) *storeHandler { } } -// @Tags store +// @Tags store // @Summary Get a store's information. // @Param id path integer true "Store Id" -// @Produce json +// @Produce json // @Success 200 {object} StoreInfo // @Failure 400 {string} string "The input is invalid." // @Failure 404 {string} string "The store does not exist." -// @Failure 500 {string} string "PD server failed to proceed the request." +// @Failure 500 {string} string "PD server failed to proceed the request." // @Router /store/{id} [get] func (h *storeHandler) GetStore(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) @@ -735,13 +735,13 @@ func (h *storesHandler) GetStoresProgress(w http.ResponseWriter, r *http.Request } // @Tags store -// @Summary Get all stores in the cluster. -// @Param state query array true "Specify accepted store states." +// @Summary Get all stores in the cluster. +// @Param state query array true "Specify accepted store states." // @Produce json -// @Success 200 {object} StoresInfo +// @Success 200 {object} StoresInfo // @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /stores [get] -// @Deprecated Better to use /stores/check instead. +// @Router /stores [get] +// @Deprecated Better to use /stores/check instead. func (h *storesHandler) GetAllStores(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) stores := rc.GetMetaStores()