Skip to content

Commit

Permalink
Merge pull request #10 from lannoy0523/issue_2655
Browse files Browse the repository at this point in the history
Issue 2655
  • Loading branch information
zacYL authored Oct 24, 2024
2 parents bea9449 + 93db9ee commit baf4e91
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ class DownloadBandwidthRateLimiterService(
rateLimiterMetrics: RateLimiterMetrics,
redisTemplate: RedisTemplate<String, String>? = null,
rateLimiterConfigService: RateLimiterConfigService
) : UploadBandwidthRateLimiterService(taskScheduler, rateLimiterProperties, rateLimiterMetrics, redisTemplate, rateLimiterConfigService) {
) : UploadBandwidthRateLimiterService(
taskScheduler,
rateLimiterProperties,
rateLimiterMetrics,
redisTemplate,
rateLimiterConfigService
) {

override fun getLimitDimensions(): List<String> {
return listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ class DownloadUsageRateLimiterService(
rateLimiterMetrics: RateLimiterMetrics,
redisTemplate: RedisTemplate<String, String>? = null,
rateLimiterConfigService: RateLimiterConfigService
) : UploadUsageRateLimiterService(taskScheduler, rateLimiterProperties, rateLimiterMetrics, redisTemplate, rateLimiterConfigService) {
) : UploadUsageRateLimiterService(
taskScheduler,
rateLimiterProperties,
rateLimiterMetrics,
redisTemplate,
rateLimiterConfigService
) {

override fun getApplyPermits(request: HttpServletRequest, applyPermits: Long?): Long {
if (applyPermits == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RateLimitController(
}
rateLimiterConfigService.getById(request.id!!).let {
if (it != null &&
(!it.resource.equals(request.resource) || !it.limitDimension.equals(request.limitDimension)) &&
updateCheckResource(it, request) &&
rateLimiterConfigService.checkExist(request)
) {
throw ErrorCodeException(
Expand All @@ -56,6 +56,10 @@ class RateLimitController(
return ResponseBuilder.success()
}

private fun updateCheckResource(tRateLimit: TRateLimit, request: RateLimitCreatOrUpdateRequest): Boolean {
return (tRateLimit.resource != request.resource || tRateLimit.limitDimension != request.limitDimension)
}

// 新增
@PostMapping("/create")
fun create(@RequestBody request:RateLimitCreatOrUpdateRequest): Response<Void> {
Expand Down

0 comments on commit baf4e91

Please sign in to comment.