Skip to content

Commit

Permalink
address the comment
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Jul 26, 2023
1 parent de38a6b commit d1c879a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,9 @@ error = '''
leader is nil
'''

["PD:server:ErrReachRateLimit"]
["PD:server:ErrRateLimitExceeded"]
error = '''
reach rate limit
rate limit exceeded
'''

["PD:server:ErrServerNotStarted"]
Expand Down
2 changes: 1 addition & 1 deletion pkg/errs/errno.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ var (
ErrCancelStartEtcd = errors.Normalize("etcd start canceled", errors.RFCCodeText("PD:server:ErrCancelStartEtcd"))
ErrConfigItem = errors.Normalize("cannot set invalid configuration", errors.RFCCodeText("PD:server:ErrConfiguration"))
ErrServerNotStarted = errors.Normalize("server not started", errors.RFCCodeText("PD:server:ErrServerNotStarted"))
ErrReachRateLimit = errors.Normalize("reach rate limit", errors.RFCCodeText("PD:server:ErrReachRateLimit"))
ErrRateLimitExceeded = errors.Normalize("rate limit exceeded", errors.RFCCodeText("PD:server:ErrRateLimitExceeded"))
)

// logutil errors
Expand Down
16 changes: 8 additions & 8 deletions server/grpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (s *GrpcServer) GetMembers(context.Context, *pdpb.GetMembersRequest) (*pdpb
defer limiter.Release(fName)
} else {
return &pdpb.GetMembersResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrReachRateLimit.FastGenByArgs().Error()),
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrRateLimitExceeded.FastGenByArgs().Error()),
}, nil
}
}
Expand Down Expand Up @@ -775,7 +775,7 @@ func (s *GrpcServer) GetStore(ctx context.Context, request *pdpb.GetStoreRequest
defer limiter.Release(fName)
} else {
return &pdpb.GetStoreResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrReachRateLimit.FastGenByArgs().Error()),
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrRateLimitExceeded.FastGenByArgs().Error()),
}, nil
}
}
Expand Down Expand Up @@ -878,7 +878,7 @@ func (s *GrpcServer) GetAllStores(ctx context.Context, request *pdpb.GetAllStore
defer limiter.Release(fName)
} else {
return &pdpb.GetAllStoresResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrReachRateLimit.FastGenByArgs().Error()),
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrRateLimitExceeded.FastGenByArgs().Error()),
}, nil
}
}
Expand Down Expand Up @@ -923,7 +923,7 @@ func (s *GrpcServer) StoreHeartbeat(ctx context.Context, request *pdpb.StoreHear
defer limiter.Release(fName)
} else {
return &pdpb.StoreHeartbeatResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrReachRateLimit.FastGenByArgs().Error()),
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrRateLimitExceeded.FastGenByArgs().Error()),
}, nil
}
}
Expand Down Expand Up @@ -1304,7 +1304,7 @@ func (s *GrpcServer) GetRegion(ctx context.Context, request *pdpb.GetRegionReque
defer limiter.Release(fName)
} else {
return &pdpb.GetRegionResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrReachRateLimit.FastGenByArgs().Error()),
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrRateLimitExceeded.FastGenByArgs().Error()),
}, nil
}
}
Expand Down Expand Up @@ -1348,7 +1348,7 @@ func (s *GrpcServer) GetPrevRegion(ctx context.Context, request *pdpb.GetRegionR
defer limiter.Release(fName)
} else {
return &pdpb.GetRegionResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrReachRateLimit.FastGenByArgs().Error()),
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrRateLimitExceeded.FastGenByArgs().Error()),
}, nil
}
}
Expand Down Expand Up @@ -1393,7 +1393,7 @@ func (s *GrpcServer) GetRegionByID(ctx context.Context, request *pdpb.GetRegionB
defer limiter.Release(fName)
} else {
return &pdpb.GetRegionResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrReachRateLimit.FastGenByArgs().Error()),
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrRateLimitExceeded.FastGenByArgs().Error()),
}, nil
}
}
Expand Down Expand Up @@ -1437,7 +1437,7 @@ func (s *GrpcServer) ScanRegions(ctx context.Context, request *pdpb.ScanRegionsR
defer limiter.Release(fName)
} else {
return &pdpb.ScanRegionsResponse{
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrReachRateLimit.FastGenByArgs().Error()),
Header: s.wrapErrorToHeader(pdpb.ErrorType_UNKNOWN, errs.ErrRateLimitExceeded.FastGenByArgs().Error()),
}, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,7 @@ func TestGRPCRateLimitMiddleware(t *testing.T) {
re.NoError(err)
resp.Body.Close()
re.Equal(http.StatusOK, resp.StatusCode)
expectErr := "reach rate limit"
expectErr := errs.ErrRateLimitExceeded.Error()
for i := 0; i < 3; i++ {
_, err := client.GetStore(ctx, 1)
if i > 0 {
Expand Down

0 comments on commit d1c879a

Please sign in to comment.