Skip to content

Conversation

gaius-qi
Copy link
Member

Description

This pull request refactors the rate limiting system by replacing the limiters library with redis_rate for distributed rate limiting. It introduces a simplified API for rate limit checks and updates related configurations and middleware. Below are the most important changes grouped by theme:

Dependency Updates:

  • Replaced github.com/mennanov/limiters with github.com/go-redis/redis_rate/v10 for distributed rate limiting. (go.mod: [1] [2] [3]
  • Removed unused dependencies, including github.com/fatih/color, github.com/hashicorp/consul/api, and others. (go.mod: [1] [2] [3]

Distributed Rate Limiter Refactor:

Job Rate Limiter Simplification:

  • Replaced TakeByClusterID and TakeByClusterIDs with AllowByClusterID and AllowByClusterIDs methods for boolean-based rate limit checks. (internal/ratelimiter/job_ratelimiter.go: [1] [2]
  • Updated the refresh method to use the new DistributedRateLimiter. (internal/ratelimiter/job_ratelimiter.go: internal/ratelimiter/job_ratelimiter.goL167-R178)

Configuration Changes:

Middleware Update:

Related Issue

Motivation and Context

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

Signed-off-by: Gaius <gaius.qi@gmail.com>
@gaius-qi gaius-qi added this to the v2.3.0 milestone May 15, 2025
@gaius-qi gaius-qi self-assigned this May 15, 2025
@gaius-qi gaius-qi requested a review from a team as a code owner May 15, 2025 07:27
@gaius-qi gaius-qi added enhancement New feature or request manager labels May 15, 2025
@gaius-qi gaius-qi changed the title feat implement distributed rate limiting by redis_rate/v10 feat: implement distributed rate limiting by redis_rate/v10 May 15, 2025
Copy link

codecov bot commented May 15, 2025

Codecov Report

Attention: Patch coverage is 0% with 26 lines in your changes missing coverage. Please review.

Project coverage is 34.41%. Comparing base (21255b1) to head (fcb4f4b).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/ratelimiter/job_ratelimiter.go 0.00% 20 Missing ⚠️
internal/ratelimiter/distributed_ratelimiter.go 0.00% 5 Missing ⚠️
manager/middlewares/ratelimiter.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4068      +/-   ##
==========================================
+ Coverage   34.28%   34.41%   +0.12%     
==========================================
  Files         344      346       +2     
  Lines       40380    40458      +78     
==========================================
+ Hits        13846    13922      +76     
- Misses      25617    25622       +5     
+ Partials      917      914       -3     
Flag Coverage Δ
unittests 34.41% <0.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
manager/middlewares/ratelimiter.go 0.00% <0.00%> (ø)
internal/ratelimiter/distributed_ratelimiter.go 0.00% <0.00%> (ø)
internal/ratelimiter/job_ratelimiter.go 0.00% <0.00%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@Liam-Zhao Liam-Zhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@chlins chlins enabled auto-merge (squash) May 15, 2025 07:37
@chlins chlins merged commit bf4c96b into main May 15, 2025
31 checks passed
@chlins chlins deleted the feature/rate-limit branch May 15, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request manager
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants