Skip to content

Conversation

@predic8
Copy link
Member

@predic8 predic8 commented Jan 4, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a new rate limiting example configuration demonstrating both global rate limiting (10 requests per minute) and per-endpoint rate limiting scenarios (3 requests per 30 seconds with user-based key expressions) for flexible traffic control.
  • Tests

    • Updated test suite for rate limiting examples with improved assertion patterns and streamlined imports.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 4, 2026

📝 Walkthrough

Walkthrough

A new rate-limiting example YAML configuration file is introduced with global and per-endpoint rate limiter scenarios. Corresponding test methods are refactored with renamed methods, consolidated imports, and updated assertion styles from explicit to generic patterns.

Changes

Cohort / File(s) Summary
New Rate Limiting Example Configuration
distribution/examples/rate-limiting/apis.yaml
Introduces two API scenario configurations: a global rate limiter (10 req/min) and a per-endpoint rate limiter (3 req/30s with JSONPath user key extraction).
Test Refactoring
distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/test/RateLimiterExampleTest.java
Renames test methods testGlobalRateLimitByClientIp()globalRateLimitByClientIp() and testEndpointSpecificRateLimitByJsonUser()endpointSpecificRateLimitByJsonUser(). Consolidates imports using wildcards (org.junit.jupiter.api.*, io.restassured.RestAssured.*, com.predic8.membrane.examples.util.*) and replaces explicit assertion calls with generic assertTrue().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A config hops in, with limits so fair,
Global and local, with utmost care,
Tests get a polish, names bright and clean,
Assertions refined—oh, what a scene!
Rate limiting flows with rabbity grace,

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding rate-limiting YAML examples and updating test methods for validation.
✨ Finishing touches
  • 📝 Generate docstrings

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
Contributor

@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: 0

🧹 Nitpick comments (1)
distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/test/RateLimiterExampleTest.java (1)

17-21: Consider explicit imports over wildcards.

While wildcard imports work fine here, explicit imports can improve code clarity by making it obvious where each class and method originates. This is particularly helpful for readers unfamiliar with the codebase and can prevent potential naming conflicts.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89397c8 and 8972f88.

📒 Files selected for processing (2)
  • distribution/examples/rate-limiting/apis.yaml
  • distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/test/RateLimiterExampleTest.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (6)
distribution/examples/rate-limiting/apis.yaml (4)

3-6: LGTM!

The global rate limiter configuration is correctly structured with a valid ISO 8601 duration format (PT1M = 1 minute).


8-14: LGTM!

The first API definition is clean and correctly demonstrates an endpoint subject to the global rate limiter.


17-30: LGTM!

The endpoint-specific rate limiter configuration correctly demonstrates per-user rate limiting using JSONPath. The keyExpression $.user appropriately extracts the user identifier from the JSON request body, and PT30S (30 seconds) is a valid ISO 8601 duration format suitable for password reset scenarios.


1-1: Align schema version with codebase standard and fix outlier.

The schema reference to v7.0.5 is consistent across nearly all configuration files in the repository. However, distribution/examples/extending-membrane/global-interceptor/apis.yaml uses v7.0.4, creating an inconsistency. Update that file to use v7.0.5 to match the rest of the codebase.

distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/test/RateLimiterExampleTest.java (2)

31-43: LGTM!

The test correctly validates the global rate limiter behavior:

  • Sends exactly 10 requests (matching the limit in apis.yaml)
  • Verifies the 11th request is rate-limited (429)
  • Confirms appropriate log entries

The method rename and assertion style updates align well with JUnit 5 conventions.


46-76: LGTM!

The test thoroughly validates endpoint-specific rate limiting:

  • Correctly sends 3 requests for Alice (matching the limit in apis.yaml)
  • Verifies Alice's 4th request is rate-limited (429)
  • Confirms Bob can still make requests (validates per-user rate limiting via $.user keyExpression)
  • Validates appropriate log entries including the user identifier and duration

The method rename and assertion style updates align well with JUnit 5 conventions.

@christiangoerdes christiangoerdes merged commit 78d5942 into master Jan 5, 2026
5 checks passed
@christiangoerdes christiangoerdes deleted the ratelimiter-yaml-example branch January 5, 2026 07:42
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.

3 participants