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

feature: support configuring scan target for GlobalTransactionScanner #2852

Merged
merged 53 commits into from
May 12, 2021

Conversation

wangliang181230
Copy link
Contributor

@wangliang181230 wangliang181230 commented Jul 2, 2020

Ⅰ. Describe what this PR did

feature: support custom scan target for GlobalTransactionScanner

配置方式1:配置只想扫描的package或需要排除的beanName:

seata:
  scan-packages: firstPackage,secondPackage
  excludes-for-scanning: firstBeanNameForExclude,secondBeanNameForExclude

配置方式2:实现扫描校验器接口,判断是否需要扫描:

扫描校验器接口:io.seata.spring.annotation.ScannerChecker
添加校验器的三种方式:

  1. 创建ScannerChecker实现类的spring bean即可,seata会自动读取所有实现了该接口的bean.
  2. 将实现类配置到各自模块下的/META-INF/service/io.seata.spring.annotation.ScannerChecker文件中。
  3. 调用GlobalTransactionScanner.addScannerCheckers(checkers)静态方法添加。(注:上面两种方式最终也是由seata自行调用此方法添加的)

seata提供的ScannerChecker

  1. io.seata.spring.annotation.scannercheckers.ScopeBeansScannerChecker:
    目前可以排除 添加了以下四种@Scope的bean : request, session, job, step.
    可自行调用ScopeBeansScannerChecker.addExcludeScopes(scopeNames)添加更多想要排除的scope类型。

  2. io.seata.spring.annotation.scannercheckers.ConfigBeansScannerChecker:
    beanName为*AutoConfiguration*Properties的bean排除掉。

Ⅱ. Does this pull request fix one issue?

fixes #2815

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-commenter
Copy link

codecov-commenter commented Jul 2, 2020

Codecov Report

Merging #2852 into develop will decrease coverage by 0.26%.
The diff coverage is 3.88%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #2852      +/-   ##
=============================================
- Coverage      50.30%   50.04%   -0.27%     
+ Complexity      3069     3068       -1     
=============================================
  Files            600      603       +3     
  Lines          19514    19616     +102     
  Branches        2408     2428      +20     
=============================================
  Hits            9817     9817              
- Misses          8714     8812      +98     
- Partials         983      987       +4     
Impacted Files Coverage Δ Complexity Δ
...ing/boot/autoconfigure/SeataAutoConfiguration.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...n/scannerexcluders/ConfigBeansScannerExcluder.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ation/scannerexcluders/PackageScannerExcluder.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...on/scannerexcluders/ScopeBeansScannerExcluder.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ta/spring/annotation/GlobalTransactionScanner.java 41.73% <6.89%> (-9.79%) 17.00 <0.00> (ø)
...boot/autoconfigure/properties/SeataProperties.java 41.02% <25.00%> (-4.14%) 7.00 <0.00> (ø)
...torage/file/store/FileTransactionStoreManager.java 56.77% <0.00%> (-0.65%) 28.00% <0.00%> (-1.00%)
...o/seata/server/coordinator/DefaultCoordinator.java 54.63% <0.00%> (-0.52%) 28.00% <0.00%> (-1.00%)
...in/java/io/seata/server/session/GlobalSession.java 83.71% <0.00%> (-0.46%) 71.00% <0.00%> (-1.00%)
... and 2 more

@wangliang181230 wangliang181230 changed the title feature: Can exclude beans that do not need to be scanned feature: Can exclude beans that do not need to be scanned in the GlobalTransactionScanner Jul 10, 2020
@xingfudeshi xingfudeshi self-requested a review July 11, 2020 04:09
@wangliang181230 wangliang181230 changed the title feature: Can exclude beans that do not need to be scanned in the GlobalTransactionScanner feature: support custom exclude beans in the GlobalTransactionScanner Sep 2, 2020
@wangliang181230 wangliang181230 changed the title feature: support custom exclude beans in the GlobalTransactionScanner feature: support custom scan target for GlobalTransactionScanner Sep 4, 2020
@codecov-io
Copy link

codecov-io commented Oct 12, 2020

Codecov Report

Merging #2852 (0da7194) into develop (be83b1e) will decrease coverage by 0.24%.
The diff coverage is 4.58%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #2852      +/-   ##
=============================================
- Coverage      50.87%   50.62%   -0.25%     
- Complexity      3280     3283       +3     
=============================================
  Files            612      615       +3     
  Lines          20113    20222     +109     
  Branches        2519     2539      +20     
=============================================
+ Hits           10233    10238       +5     
- Misses          8853     8953     +100     
- Partials        1027     1031       +4     
Impacted Files Coverage Δ Complexity Δ
...ing/boot/autoconfigure/SeataAutoConfiguration.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ion/scannercheckers/ConfigBeansScannerChecker.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...otation/scannercheckers/PackageScannerChecker.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...tion/scannercheckers/ScopeBeansScannerChecker.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ta/spring/annotation/GlobalTransactionScanner.java 39.86% <9.67%> (-8.36%) 18.00 <4.00> (+1.00) ⬇️
...boot/autoconfigure/properties/SeataProperties.java 41.02% <25.00%> (-4.14%) 7.00 <0.00> (ø)

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

# Conflicts:
#	seata-spring-boot-starter/src/main/java/io/seata/spring/boot/autoconfigure/SeataAutoConfiguration.java
@funky-eyes funky-eyes added this to the 1.5.0 milestone May 12, 2021
@funky-eyes funky-eyes added module/seata-spring-boot-starter seata-spring-boot-starter module module/spring spring module type: feature Category issues or prs related to feature request. labels May 12, 2021
…scanner

# Conflicts:
#	changes/1.5.0.md
#	changes/en-us/1.5.0.md
#	spring/src/main/java/io/seata/spring/annotation/GlobalTransactionScanner.java
@codecov-commenter
Copy link

codecov-commenter commented May 12, 2021

Codecov Report

Merging #2852 (1ae4c0d) into develop (965a48d) will decrease coverage by 0.34%.
The diff coverage is 4.54%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #2852      +/-   ##
=============================================
- Coverage      51.56%   51.21%   -0.35%     
- Complexity      3564     3565       +1     
=============================================
  Files            641      644       +3     
  Lines          21624    21732     +108     
  Branches        2710     2699      -11     
=============================================
- Hits           11150    11130      -20     
- Misses          9342     9442     +100     
- Partials        1132     1160      +28     
Impacted Files Coverage Δ Complexity Δ
...ing/boot/autoconfigure/SeataAutoConfiguration.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ion/scannercheckers/ConfigBeansScannerChecker.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...otation/scannercheckers/PackageScannerChecker.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...tion/scannercheckers/ScopeBeansScannerChecker.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ta/spring/annotation/GlobalTransactionScanner.java 28.71% <9.67%> (-3.60%) 18.00 <4.00> (+1.00) ⬇️
...boot/autoconfigure/properties/SeataProperties.java 41.02% <25.00%> (-4.14%) 7.00 <0.00> (ø)
...obuf/convertor/BranchRegisterRequestConvertor.java 90.47% <0.00%> (-9.53%) 3.00% <0.00%> (ø%)
...otobuf/convertor/GlobalBeginResponseConvertor.java 92.59% <0.00%> (-7.41%) 3.00% <0.00%> (ø%)
...otobuf/convertor/GlobalCommitRequestConvertor.java 93.75% <0.00%> (-6.25%) 3.00% <0.00%> (ø%)
...otobuf/convertor/GlobalStatusRequestConvertor.java 93.75% <0.00%> (-6.25%) 3.00% <0.00%> (ø%)
... and 22 more

@wangliang181230 wangliang181230 changed the title feature: support custom scan target for GlobalTransactionScanner feature: support configuring scan target for GlobalTransactionScanner May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/seata-spring-boot-starter seata-spring-boot-starter module module/spring spring module type: feature Category issues or prs related to feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

seata与springbatch发生出冲突
5 participants