Skip to content
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

support consumer routers config #1416

Merged
merged 2 commits into from
May 17, 2024

Conversation

EvenLjj
Copy link
Collaborator

@EvenLjj EvenLjj commented May 16, 2024

support consumer routers config

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration option for consumer routers.
  • Improvements

    • Enhanced consumer router initialization and configuration handling.
  • Testing

    • Added new tests to validate the functionality of consumer routers.
    • Updated existing tests for better coverage and accuracy.
  • Configuration

    • Updated rpc-config.json and rpc-config-default.json to include new consumer router configurations.

@sofastack-cla sofastack-cla bot added cla:yes CLA is ok size/M labels May 16, 2024
Copy link
Contributor

coderabbitai bot commented May 16, 2024

Walkthrough

The recent update enhances router configurations in the Sofa RPC framework with a new constant CONSUMER_ROUTERS, empowering consumer configuration capabilities. Changes encompass initializing and managing router lists in ConsumerConfig, adjusting related tests, and updating configuration files to support the new router settings.

Changes

Files Change Summary
RouterChain.java
FilterChain.java
Refactored loop processing for routerAliases and filterAliases using streams for improved handling. Removed unnecessary assignments.
RouterChainTest.java Removed config.setRouter call from buildProviderChain method.
ConsumerConfigTest.java Added imports, modified test methods, and introduced a new test for router functionality.
rpc-config.json Added consumer.routers configuration with specific router names.
rpc-config-default.json Added consumer.routers configuration with an empty array value.

In code's realm where changes gleam,
New routers lead in the grand scheme.
Tests refined, configs align,
Consumer paths now intertwine.
With lists of routers, we progress,
In Sofa's world, we find success.
🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between d6d5c85 and 27603ea.
Files selected for processing (6)
  • core/api/src/main/java/com/alipay/sofa/rpc/common/RpcOptions.java (1 hunks)
  • core/api/src/main/java/com/alipay/sofa/rpc/config/ConsumerConfig.java (4 hunks)
  • core/api/src/test/java/com/alipay/sofa/rpc/client/RouterChainTest.java (1 hunks)
  • core/api/src/test/java/com/alipay/sofa/rpc/std/config/ConsumerConfigTest.java (3 hunks)
  • core/api/src/test/resources/sofa-rpc/rpc-config.json (1 hunks)
  • core/common/src/main/resources/com/alipay/sofa/rpc/common/rpc-config-default.json (1 hunks)
Files skipped from review due to trivial changes (3)
  • core/api/src/main/java/com/alipay/sofa/rpc/common/RpcOptions.java
  • core/api/src/test/java/com/alipay/sofa/rpc/client/RouterChainTest.java
  • core/common/src/main/resources/com/alipay/sofa/rpc/common/rpc-config-default.json
Additional comments not posted (5)
core/api/src/test/resources/sofa-rpc/rpc-config.json (1)

5-5: Configuration for consumer routers added correctly.

core/api/src/test/java/com/alipay/sofa/rpc/std/config/ConsumerConfigTest.java (2)

66-66: Assertion for router list added correctly.


127-138: Router-related tests added correctly.

core/api/src/main/java/com/alipay/sofa/rpc/config/ConsumerConfig.java (2)

179-180: Router list initialized correctly from configuration.


689-699: Method to append routers added correctly.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 27603ea and 796518e.
Files selected for processing (3)
  • core/api/src/main/java/com/alipay/sofa/rpc/client/RouterChain.java (3 hunks)
  • core/api/src/main/java/com/alipay/sofa/rpc/filter/FilterChain.java (2 hunks)
  • core/api/src/test/resources/sofa-rpc/rpc-config.json (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • core/api/src/test/resources/sofa-rpc/rpc-config.json
Additional comments not posted (3)
core/api/src/main/java/com/alipay/sofa/rpc/client/RouterChain.java (2)

Line range hint 146-155: Refactoring to use Java streams enhances readability and maintainability.


Line range hint 146-155: Verify the impact of removing excludes = null; on the lifecycle of the excludes set.

Verification successful

The removal of the assignment excludes = null; does not introduce memory leaks or logical errors. The excludes set is properly managed through its initialization and usage within the RouterChain class.

  • excludes is initialized using parseExcludeRouter(customRouters).
  • It is used to add elements and check for containment without requiring explicit null assignment.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the usage of `excludes` set throughout the RouterChain class to ensure no memory leaks or logical errors are introduced by its removal.

# Test: Search for the usage of `excludes`. Expect: Proper management without explicit null assignment.
rg --type java 'HashSet<String> excludes' core/api/src/main/java/com/alipay/sofa/rpc/client/RouterChain.java

Length of output: 180



Script:

#!/bin/bash
# Description: Verify the usage of `excludes` set throughout the RouterChain class to ensure no memory leaks or logical errors are introduced by its removal.

# Test: Search for all usages of `excludes` in the RouterChain class.
rg --type java 'excludes' core/api/src/main/java/com/alipay/sofa/rpc/client/RouterChain.java

Length of output: 398

core/api/src/main/java/com/alipay/sofa/rpc/filter/FilterChain.java (1)

Line range hint 196-205: Refactoring to use Java streams in processing filter aliases improves clarity and reduces error-proneness.

Copy link
Collaborator

@chuailiwu chuailiwu left a comment

Choose a reason for hiding this comment

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

lgtm

@EvenLjj EvenLjj merged commit c7a45ea into sofastack:master May 17, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants