Skip to content

Commit

Permalink
Refine the naming
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Oct 31, 2023
1 parent ac5e679 commit 171e66d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions br/pkg/pdutil/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (p *PdController) getRegionCountWith(
}
var err error
for _, addr := range p.getAllPDAddrs() {
v, e := get(ctx, addr, pdapi.RegionStatsWithStartEndKey(start, end), p.cli, http.MethodGet, nil)
v, e := get(ctx, addr, pdapi.RegionStatsByStartEndKey(start, end), p.cli, http.MethodGet, nil)
if e != nil {
err = e
continue
Expand All @@ -409,7 +409,7 @@ func (p *PdController) getStoreInfoWith(
ctx context.Context, get pdHTTPRequest, storeID uint64) (*pdtypes.StoreInfo, error) {
var err error
for _, addr := range p.getAllPDAddrs() {
v, e := get(ctx, addr, pdapi.StoreWithID(storeID), p.cli, http.MethodGet, nil)
v, e := get(ctx, addr, pdapi.StoreByID(storeID), p.cli, http.MethodGet, nil)
if e != nil {
err = e
continue
Expand All @@ -435,7 +435,7 @@ func (p *PdController) doPauseSchedulers(ctx context.Context,
removedSchedulers := make([]string, 0, len(schedulers))
for _, scheduler := range schedulers {
for _, addr := range p.getAllPDAddrs() {
_, err = post(ctx, addr, pdapi.SchedulerWithName(scheduler), p.cli, http.MethodPost, bytes.NewBuffer(body))
_, err = post(ctx, addr, pdapi.SchedulerByName(scheduler), p.cli, http.MethodPost, bytes.NewBuffer(body))
if err == nil {
removedSchedulers = append(removedSchedulers, scheduler)
break
Expand Down Expand Up @@ -517,7 +517,7 @@ func (p *PdController) resumeSchedulerWith(ctx context.Context, schedulers []str
}
for _, scheduler := range schedulers {
for _, addr := range p.getAllPDAddrs() {
_, err = post(ctx, addr, pdapi.SchedulerWithName(scheduler), p.cli, http.MethodPost, bytes.NewBuffer(body))
_, err = post(ctx, addr, pdapi.SchedulerByName(scheduler), p.cli, http.MethodPost, bytes.NewBuffer(body))
if err == nil {
break
}
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/pdutil/pd_serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func TestStoreInfo(t *testing.T) {
_ context.Context, addr string, prefix string, _ *http.Client, _ string, _ io.Reader,
) ([]byte, error) {
require.Equal(t,
fmt.Sprintf("http://mock%s", pdapi.StoreWithID(1)),
fmt.Sprintf("http://mock%s", pdapi.StoreByID(1)),
fmt.Sprintf("%s%s", addr, prefix))
ret, err := json.Marshal(storeInfo)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/restore/split/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ func (c *pdClient) SetStoresLabel(
for _, id := range stores {
req, err := http.NewRequestWithContext(
ctx, "POST",
addr+pdapi.StoreLabelWithID(id),
addr+pdapi.StoreLabelByID(id),
bytes.NewReader(b),
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/domain/infosync/tiflash_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func (m *TiFlashReplicaManagerCtx) GetRegionCountFromPD(ctx context.Context, tab
startKey, endKey = m.codec.EncodeRegionRange(startKey, endKey)

p := fmt.Sprintf("%s&count",
pdapi.RegionStatsWithStartEndKey(
pdapi.RegionStatsByStartEndKey(
url.QueryEscape(string(startKey)),
url.QueryEscape(string(endKey)),
))
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ func (h *Helper) GetPDRegionStats(tableID int64, stats *PDRegionStats, noIndexSt
statURL := fmt.Sprintf("%s://%s%s",
util.InternalHTTPSchema(),
pdAddrs[0],
pdapi.RegionStatsWithStartEndKey(
pdapi.RegionStatsByStartEndKey(
url.QueryEscape(string(startKey)),
url.QueryEscape(string(endKey)),
))
Expand Down
16 changes: 8 additions & 8 deletions pkg/util/pdapi/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ func ConfigWithTTLSeconds(ttlSeconds float64) string {
return fmt.Sprintf("%s?ttlSecond=%.0f", Config, ttlSeconds)
}

// StoreWithID returns the store API with store ID parameter.
func StoreWithID(id uint64) string {
// StoreByID returns the store API with store ID parameter.
func StoreByID(id uint64) string {
return fmt.Sprintf("%s/%d", store, id)
}

// StoreLabelWithID returns the store label API with store ID parameter.
func StoreLabelWithID(id uint64) string {
// StoreLabelByID returns the store label API with store ID parameter.
func StoreLabelByID(id uint64) string {
return fmt.Sprintf("%s/%d/label", store, id)
}

// RegionStatsWithStartEndKey returns the region stats API with start key and end key parameters.
func RegionStatsWithStartEndKey(startKey, endKey string) string {
// RegionStatsByStartEndKey returns the region stats API with start key and end key parameters.
func RegionStatsByStartEndKey(startKey, endKey string) string {
return fmt.Sprintf("%s?start_key=%s&end_key=%s", RegionStats, startKey, endKey)
}

// SchedulerWithName returns the scheduler API with the given scheduler name.
func SchedulerWithName(name string) string {
// SchedulerByName returns the scheduler API with the given scheduler name.
func SchedulerByName(name string) string {
return fmt.Sprintf("%s/%s", Schedulers, name)
}

Expand Down

0 comments on commit 171e66d

Please sign in to comment.