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

Enhanced for Nacos weight configuration #1406

Conversation

wangchengming666
Copy link
Collaborator

@wangchengming666 wangchengming666 commented Mar 19, 2024

Enhanced for Nacos weight configuration

Summary by CodeRabbit

  • New Features
    • Enhanced provider weight adjustment based on Nacos instance weights for better compatibility within the SOFA-RPC framework.
  • Tests
    • Added tests to ensure accurate weight calculation for Nacos instances.

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

coderabbitai bot commented Mar 19, 2024

Walkthrough

The recent update enhances compatibility by aligning provider weights in the SOFA-RPC framework with Nacos instance weights. It also includes new tests to validate weight calculations for Nacos instances under various weight scenarios.

Changes

Files Change Summary
.../nacos/NacosRegistryHelper.java Adjusted provider weights based on Nacos instance weights for compatibility.
.../nacos/NacosRegistryHelperTest.java Added tests for weight calculation with positive, negative, and zero weights.

🐰✨
In the land of code where the Nacos play,
We've tweaked the weights in a clever way.
With tests to check, both night and day,
Ensuring weights are right, come what may.
🌟🐾

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-tests 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 tests 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 tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ac2a73e and 63a2efc.
Files selected for processing (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java (1 hunks)
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (1 hunks)

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.05%. Comparing base (e67ea54) to head (b0dce31).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1406   +/-   ##
=========================================
  Coverage     72.04%   72.05%           
- Complexity      791      792    +1     
=========================================
  Files           422      422           
  Lines         17814    17814           
  Branches       2768     2768           
=========================================
+ Hits          12834    12835    +1     
+ Misses         3565     3564    -1     
  Partials       1415     1415           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 63a2efc and 3071ad0.
Files selected for processing (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java (1 hunks)
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3071ad0 and ba4e34e.
Files selected for processing (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java (1 hunks)
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java
Additional comments: 3
registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (3)
  • 140-156: The test method testNacosWeight correctly tests the scenario where the Nacos instance weight is less than 1 but greater than 0. However, it's important to ensure that the conversion logic in NacosRegistryHelper.convertInstancesToProviders correctly handles edge cases and rounding. Consider adding assertions to verify the expected behavior when the weight is exactly 1 or slightly above, to ensure comprehensive coverage.
  • 159-175: The method testNacosWeightLessThan0 tests negative weights, which is a good practice to ensure robustness. However, it's crucial to verify if negative weights are valid within the context of Nacos and SOFA-RPC. If negative weights are not intended to be used, this test might validate an undesired behavior. Please confirm the expected behavior regarding negative weights and adjust the test or the implementation accordingly.
  • 178-194: The testNacosWeightWith0 method effectively tests the scenario where the weight is zero. This is crucial for ensuring that edge cases are handled correctly. Given the importance of edge cases in weight calculations, consider adding more tests for other boundary values, such as the maximum possible weight, to ensure the system behaves as expected across the entire range of valid weights.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ba4e34e and 7c12b24.
Files selected for processing (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java (1 hunks)
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java

@EvenLjj EvenLjj force-pushed the enhanced_for_Nacos_weight_configuration branch from 9437132 to 4a5a31d Compare March 26, 2024 11:06
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 70f16f3 and 4a5a31d.
Files selected for processing (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java (1 hunks)
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java

@EvenLjj EvenLjj force-pushed the enhanced_for_Nacos_weight_configuration branch from 4a5a31d to a368029 Compare March 26, 2024 11:46
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 70f16f3 and a368029.
Files ignored due to path filters (1)
  • tracer/tracer-opentracing/pom.xml is excluded by: !**/*.xml
Files selected for processing (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java (1 hunks)
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java

@EvenLjj EvenLjj force-pushed the enhanced_for_Nacos_weight_configuration branch from a368029 to cd22e96 Compare March 26, 2024 11:58
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 70f16f3 and cd22e96.
Files ignored due to path filters (1)
  • tracer/tracer-opentracing/pom.xml is excluded by: !**/*.xml
Files selected for processing (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java (1 hunks)
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java

@EvenLjj EvenLjj force-pushed the enhanced_for_Nacos_weight_configuration branch from cd22e96 to 1842b8f Compare March 26, 2024 13:15
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 70f16f3 and 1842b8f.
Files selected for processing (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java (1 hunks)
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java

@EvenLjj EvenLjj closed this Mar 26, 2024
@EvenLjj EvenLjj reopened this Mar 26, 2024
@EvenLjj EvenLjj force-pushed the enhanced_for_Nacos_weight_configuration branch from 1842b8f to b0dce31 Compare March 27, 2024 08:58
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e67ea54 and b0dce31.
Files selected for processing (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java (1 hunks)
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • registry/registry-nacos/src/main/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelper.java
  • registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java

Copy link
Collaborator

@EvenLjj EvenLjj 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 a97d72c into sofastack:master Mar 28, 2024
5 checks passed
@wangchengming666 wangchengming666 deleted the enhanced_for_Nacos_weight_configuration branch March 28, 2024 05:14
@EvenLjj EvenLjj added this to the 5.13.0 milestone Apr 30, 2024
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.

4 participants