Skip to content

Add rate limit to Port client #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

erikzaadi
Copy link
Member

Description

What - Add rate limit capabilities to the base port http client
Why - Prevent failing on multiple 429
How - Add resty middle ware that detects rate limits and acts accordingly

Type of change

Please leave one option from the following and delete the rest:

  • 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 not work as expected)
  • Non-breaking change (fix of existing functionality that will not change current behavior)
  • Documentation (added/updated documentation)

@erikzaadi erikzaadi force-pushed the PORT-15207-rate-limit branch from 99b4284 to 01d6aa3 Compare June 23, 2025 18:56
Copy link

github-actions bot commented Jun 23, 2025

TestsPassed ✅SkippedFailedTime ⏱
JUnit Test Report9 ran9 ✅0 ⚠️0 ❌1m 2s 90ms

Copy link

Code Coverage Artifact 📈: https://github.com/port-labs/terraform-provider-port-labs/actions/runs/15832472715/artifacts/3386161105

Code Coverage Total Percentage: 41.5%

Copy link

🚨 The new code coverage percentage is lower than the current one. Current coverage: 71.4
While the new one is: 41.5

Copy link

Code Coverage Artifact 📈: https://github.com/port-labs/terraform-provider-port-labs/actions/runs/15832678263/artifacts/3386278375

Code Coverage Total Percentage: 63.1%

Copy link

🚨 The new code coverage percentage is lower than the current one. Current coverage: 71.4
While the new one is: 63.1

Copy link
Contributor

@Eyal-Shalev Eyal-Shalev left a comment

Choose a reason for hiding this comment

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

There are 2 things I don't like about this PR:

  1. You are implementing a rate limit yourself which seems an unnecessary complication. I'm sure there are great libraries for something this important.
  2. The rate limit is set globally. Shouldn't it only affect retries on the same request?

Comment on lines 678 to 683
type RateLimitInfo struct {
Limit int `json:"limit"` // x-ratelimit-limit
Period int `json:"period"` // x-ratelimit-period
Remaining int `json:"remaining"` // x-ratelimit-remaining
Reset int `json:"reset"` // x-ratelimit-reset (seconds until reset)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to add json tags if we are not marshalling this model

@erikzaadi erikzaadi force-pushed the PORT-15207-rate-limit branch from 2bc681c to 889d9e2 Compare June 24, 2025 08:59
Copy link

Code Coverage Artifact 📈: https://github.com/port-labs/terraform-provider-port-labs/actions/runs/15846001956/artifacts/3390640592

Code Coverage Total Percentage: 66.1%

Copy link

🚨 The new code coverage percentage is lower than the current one. Current coverage: 71.4
While the new one is: 66.1

Copy link

Code Coverage Artifact 📈: https://github.com/port-labs/terraform-provider-port-labs/actions/runs/15846038502/artifacts/3390655240

Code Coverage Total Percentage: 78.1%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants