Skip to content

Commit

Permalink
remove max
Browse files Browse the repository at this point in the history
Signed-off-by: wangbaiping/wbpcode <wangbaiping@bytedance.com>
  • Loading branch information
wbpcode committed Dec 23, 2024
1 parent df1198a commit fb1d0fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/limiter/base_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (this *BaseRateLimiter) checkOverLimitThreshold(limitInfo *LimitInfo, hitsA

// If the limit before increase was below the over limit value, then some of the hits were
// in the near limit range.
limitInfo.limit.Stats.NearLimit.Add(limitInfo.overLimitThreshold - utils.Max(limitInfo.nearLimitThreshold, limitInfo.limitBeforeIncrease))
limitInfo.limit.Stats.NearLimit.Add(limitInfo.overLimitThreshold - max(limitInfo.nearLimitThreshold, limitInfo.limitBeforeIncrease))
}
}

Expand Down
9 changes: 1 addition & 8 deletions src/utils/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ func CalculateReset(unit *pb.RateLimitResponse_RateLimit_Unit, timeSource TimeSo
return &durationpb.Duration{Seconds: sec - now%sec}
}

func Max(a uint64, b uint64) uint64 {
if a > b {
return a
}
return b
}

// Mask credentials from a redis connection string like
// foo,redis://user:pass@redisurl1,redis://user:pass@redisurl2
// resulting in
Expand Down Expand Up @@ -83,7 +76,7 @@ func GetHitsAddends(request *pb.RateLimitRequest) []uint64 {
} else {
// If the per descriptor hits_addend is not set, use the request's hits_addend. If the value is
// zero (default value if not specified by the caller), use 1 for backward compatibility.
hitsAddends[i] = uint64(Max(1, uint64(request.HitsAddend)))
hitsAddends[i] = uint64(max(1, uint64(request.HitsAddend)))
}
}
return hitsAddends
Expand Down

0 comments on commit fb1d0fa

Please sign in to comment.