Skip to content

feat(manager): add ratelimiter for job oapi#4088

Merged
gaius-qi merged 1 commit intomainfrom
feature/add-ratelimit
May 20, 2025
Merged

feat(manager): add ratelimiter for job oapi#4088
gaius-qi merged 1 commit intomainfrom
feature/add-ratelimit

Conversation

@gaius-qi
Copy link
Copy Markdown
Member

Description

This pull request includes the removal of a large test file and the addition of a rate limiter middleware to a job creation endpoint. Below are the key changes:

Test file removal:

  • The file client/daemon/peer/piece_dispatcher_test.go was entirely removed. This file contained extensive test code for the PieceDispatcher functionality, including helper classes, test cases, and concurrency logic.

Middleware addition:

  • In manager/router/router.go, a rate limiter middleware (middlewares.CreateJobRateLimiter) was added to the POST endpoint for job creation (/jobs). This change aims to control the rate of job creation requests.

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.

@gaius-qi gaius-qi added this to the v2.3.0 milestone May 20, 2025
@gaius-qi gaius-qi self-assigned this May 20, 2025
@gaius-qi gaius-qi requested a review from a team as a code owner May 20, 2025 09:38
@gaius-qi gaius-qi added the enhancement New feature or request label May 20, 2025
@gaius-qi gaius-qi requested review from chlins, hyy0322 and imeoer May 20, 2025 09:38
chlins
chlins previously approved these changes May 20, 2025
Copy link
Copy Markdown
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 20, 2025 09:39
Liam-Zhao
Liam-Zhao previously approved these changes May 20, 2025
Copy link
Copy Markdown

@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

BruceAko
BruceAko previously approved these changes May 20, 2025
Copy link
Copy Markdown
Member

@BruceAko BruceAko left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link
Copy Markdown

codecov bot commented May 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 33.26%. Comparing base (cee86a5) to head (79ccf74).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
manager/router/router.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           main    #4088       +/-   ##
=========================================
+ Coverage      0   33.26%   +33.26%     
=========================================
  Files         0      346      +346     
  Lines         0    40493    +40493     
=========================================
+ Hits          0    13471    +13471     
- Misses        0    26131    +26131     
- Partials      0      891      +891     
Flag Coverage Δ
unittests 33.26% <0.00%> (?)

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

Files with missing lines Coverage Δ
manager/router/router.go 0.00% <0.00%> (ø)

... and 345 files with indirect coverage changes

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

Signed-off-by: Gaius <gaius.qi@gmail.com>
@gaius-qi gaius-qi dismissed stale reviews from BruceAko, Liam-Zhao, and chlins via 79ccf74 May 20, 2025 09:45
@gaius-qi gaius-qi force-pushed the feature/add-ratelimit branch from c259175 to 79ccf74 Compare May 20, 2025 09:45
Copy link
Copy Markdown
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

@gaius-qi gaius-qi disabled auto-merge May 20, 2025 10:13
@gaius-qi gaius-qi merged commit c63b794 into main May 20, 2025
27 of 32 checks passed
@gaius-qi gaius-qi deleted the feature/add-ratelimit branch May 20, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants