Skip to content

feat: wire rate limiting config in core#77

Merged
ankurs merged 3 commits intomainfrom
feat/rate-limit-config
Apr 9, 2026
Merged

feat: wire rate limiting config in core#77
ankurs merged 3 commits intomainfrom
feat/rate-limit-config

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented Apr 9, 2026

Summary

  • Add RATE_LIMIT_PER_SECOND, RATE_LIMIT_BURST, DISABLE_RATE_LIMIT config fields
  • Wire to interceptors in processConfig()
  • Regenerate READMEs via make doc
  • Per-pod in-memory limit — with N pods, effective cluster-wide limit is N × configured rate. Disabled by default (0 rps).

Depends on: go-coldbrew/interceptors#39

Test plan

  • make test passes (with local replace directive for interceptors)
  • make lint clean
  • make doc run

Summary by CodeRabbit

  • New Features

    • Added rate-limiting configuration options: RATE_LIMIT_PER_SECOND, RATE_LIMIT_BURST, and DISABLE_RATE_LIMIT environment variables to control per-pod request throttling behavior and toggle the rate limiting interceptor.
  • Documentation

    • Updated API reference documentation links.

Add RATE_LIMIT_PER_SECOND, RATE_LIMIT_BURST, DISABLE_RATE_LIMIT config
fields. Wire to interceptors in processConfig. Regenerate READMEs.

Per-pod in-memory limit — with N pods, effective cluster-wide limit is
N × configured rate. Disabled by default (0 rps).

Depends on: go-coldbrew/interceptors (rate limit interceptor)
Copilot AI review requested due to automatic review settings April 9, 2026 10:30
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Warning

Rate limit exceeded

@ankurs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 55 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 55 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c654a140-02d9-49ac-983e-5b06a4e09376

📥 Commits

Reviewing files that changed from the base of the PR and between 0b2dfc0 and 02ec0d3.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • config/config.go
  • go.mod
📝 Walkthrough

Walkthrough

This pull request adds rate-limiting configuration support to the application by introducing three new configuration fields (RateLimitPerSecond, RateLimitBurst, DisableRateLimit) to the Config struct and implementing logic in processConfig() to conditionally apply rate-limiting interceptor settings based on these configuration values.

Changes

Cohort / File(s) Summary
Documentation Updates
README.md, config/README.md
Updated API reference anchors to reflect new source-line locations for exported functions and updated Config documentation to reflect newly added rate-limiting fields.
Configuration Structure
config/config.go
Added three new environment-driven configuration fields to Config struct: RateLimitPerSecond (float64), RateLimitBurst (int), and DisableRateLimit (bool) with corresponding environment variable mappings and defaults.
Configuration Application
core.go
Implemented conditional logic in processConfig() to apply rate-limiting interceptor configuration based on the new Config fields; calls interceptors.SetDisableRateLimit() or interceptors.SetDefaultRateLimit() as appropriate.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • vestor
  • fajran
  • kevinjom
  • svetha-cvl

Poem

🐰 A hop through config knobs so fine,
Rate limits now align with thine,
Per-second bursts, disable too,
Interceptors do what they do! 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: wire rate limiting config in core' is clear, concise, and directly reflects the main purpose of the changeset—wiring rate limiting configuration fields to the core interceptor processing logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rate-limit-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class, env-driven rate limiting configuration to core by extending config.Config and wiring the values into the interceptors package during startup, with regenerated documentation reflecting the new settings.

Changes:

  • Add RATE_LIMIT_PER_SECOND, RATE_LIMIT_BURST, and DISABLE_RATE_LIMIT fields to config.Config.
  • Wire rate limit configuration into cb.processConfig() via interceptors setters.
  • Regenerate GoDoc-style READMEs to include updated line anchors and the new config fields.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
README.md Regenerated doc links/anchors to match updated core.go line numbers.
core.go Applies rate limiting configuration during processConfig() by calling interceptors setters.
config/README.md Regenerated config documentation to include the new rate limiting fields.
config/config.go Adds the new rate limiting config fields to Config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core.go
Comment thread config/config.go
Comment thread core.go
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@config/config.go`:
- Around line 123-132: The Validate() function should emit warnings for invalid
rate-limit combinations: detect when RateLimitPerSecond > 0 and RateLimitBurst
<= 0 and log/return a validation warning (or fix to set a sane default) to avoid
accidental full throttling; also warn if DisableRateLimit is true but
RateLimitPerSecond > 0 (conflicting config). Update the Validate()
implementation to check RateLimitPerSecond, RateLimitBurst, and DisableRateLimit
and produce clear warnings referencing the fields RateLimitPerSecond,
RateLimitBurst, and DisableRateLimit so operators see the misconfiguration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d0a753a3-c589-4576-b09a-f3e2e369ead0

📥 Commits

Reviewing files that changed from the base of the PR and between 1b6160f and 0b2dfc0.

📒 Files selected for processing (4)
  • README.md
  • config/README.md
  • config/config.go
  • core.go

Comment thread config/config.go
Warn on negative RateLimitPerSecond and RateLimitBurst <= 0 when
rate limiting is configured.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core.go
@ankurs ankurs merged commit b99af5a into main Apr 9, 2026
7 checks passed
@ankurs ankurs deleted the feat/rate-limit-config branch April 9, 2026 11:52
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