Skip to content

Conversation

@slievrly
Copy link
Member

@slievrly slievrly commented Sep 1, 2025

Ⅰ. Describe what this PR did

Refactor DataSourceProxy

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Sep 1, 2025

Codecov Report

❌ Patch coverage is 80.74074% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.52%. Comparing base (8763897) to head (3107c33).
⚠️ Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...rce/initializer/db/OscarResourceIdInitializer.java 25.00% 6 Missing ⚠️
...initializer/db/SqlServerResourceIdInitializer.java 78.57% 1 Missing and 5 partials ⚠️
...source/initializer/db/DMResourceIdInitializer.java 80.95% 1 Missing and 3 partials ⚠️
...rce/initializer/db/MysqlResourceIdInitializer.java 81.25% 1 Missing and 2 partials ⚠️
...nitializer/db/PostgresqlResourceIdInitializer.java 86.95% 0 Missing and 3 partials ⚠️
...ce/initializer/db/OracleResourceIdInitializer.java 75.00% 1 Missing and 1 partial ⚠️
...rce/initializer/ResourceIdInitializerRegistry.java 92.85% 1 Missing ⚠️
...e/initializer/db/DefaultResourceIdInitializer.java 87.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7615      +/-   ##
============================================
- Coverage     61.52%   61.52%   -0.01%     
  Complexity      680      680              
============================================
  Files          1314     1323       +9     
  Lines         49890    49930      +40     
  Branches       5878     5881       +3     
============================================
+ Hits          30696    30719      +23     
- Misses        16404    16420      +16     
- Partials       2790     2791       +1     
Files with missing lines Coverage Δ
...rg/apache/seata/rm/datasource/DataSourceProxy.java 62.50% <100.00%> (-5.38%) ⬇️
...rce/initializer/AbstractResourceIdInitializer.java 100.00% <100.00%> (ø)
...rce/initializer/ResourceIdInitializerRegistry.java 92.85% <92.85%> (ø)
...e/initializer/db/DefaultResourceIdInitializer.java 87.50% <87.50%> (ø)
...ce/initializer/db/OracleResourceIdInitializer.java 75.00% <75.00%> (ø)
...rce/initializer/db/MysqlResourceIdInitializer.java 81.25% <81.25%> (ø)
...nitializer/db/PostgresqlResourceIdInitializer.java 86.95% <86.95%> (ø)
...source/initializer/db/DMResourceIdInitializer.java 80.95% <80.95%> (ø)
...rce/initializer/db/OscarResourceIdInitializer.java 25.00% <25.00%> (ø)
...initializer/db/SqlServerResourceIdInitializer.java 78.57% <78.57%> (ø)

... and 8 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@YongGoose YongGoose requested a review from Copilot September 9, 2025 11:51
Copy link

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

This PR refactors the DataSourceProxy class by extracting database-specific resource ID initialization logic into separate initializer classes using a registry pattern. This improves code organization and maintainability by removing the large if-else chain from the DataSourceProxy.

  • Extracted resource ID initialization logic into separate database-specific initializer classes
  • Created a registry pattern to manage and select appropriate initializers
  • Simplified the DataSourceProxy class by delegating initialization to the registry system

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
DataSourceProxy.java Removed database-specific initialization methods and replaced with registry-based delegation
ResourceIdInitializer.java New interface defining the contract for resource ID initializers
AbstractResourceIdInitializer.java Abstract base class providing common initialization structure
ResourceIdInitializerRegistry.java Registry class managing all database-specific initializers
*ResourceIdInitializer.java Database-specific initializer implementations (MySQL, PostgreSQL, Oracle, etc.)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

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

LGTM

@funky-eyes funky-eyes added this to the 2.6.0 milestone Oct 16, 2025
@funky-eyes funky-eyes added type: refactor refactor module module/rm-datasource rm-datasource module labels Oct 16, 2025
@funky-eyes funky-eyes merged commit ca44cfe into apache:2.x Oct 16, 2025
11 checks passed
slievrly added a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module/rm-datasource rm-datasource module type: refactor refactor module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants