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

optimize: Enhance TCC annotation @BusinessActionContextParameter #3728

Draft
wants to merge 161 commits into
base: 2.x
Choose a base branch
from

Conversation

wangliang181230
Copy link
Contributor

@wangliang181230 wangliang181230 commented May 13, 2021

optimize: Enhance TCC annotation @BusinessActionContextParameter

  1. @BusinessActionContextParameter(paramName) becomes optional
  2. @BusinessActionContextParameter(index) supports used to the Array param or field
  3. @BusinessActionContextParameter: add new property fecther, it can custom the parameter fetcher. The default fetcher is DefaultParameterFetcher.

优化:增强TCC注解@BusinessActionContextParameter的功能。

  1. @BusinessActionContextParameterparamNamevalue变为可选项。可以不用设置了,未设置时,TCC会自动读取方法参数名属性名
    // 注:要想自动获取到方法参数名,前提是源码编译命令需加上-parameters参数进行编译。

  2. @BusinessActionContextParameterindex支持使用在Array类型的参数或属性上。
    // 注:现已添加ParameterFetcher的功能,建议使用该功能来自定义获取列表或数组的数据。

  3. @BusinessActionContextParameter(isParamInProperty = true)时,提取context的方法设置成了一个接口ParameterFetcher,并可自定义实现。原来的fetch代码转移到默认接口实现DefaultParameterFetcher中。

    目前,设想的fetcher的使用场景有以下两种:

    1. 默认的DefaultParameterFetcher,使用的是反射来提取context,部分对性能要求比较高的用户,可自定义实现,来提升性能。
    2. 默认的DefaultParameterFetcher无法满足需求时,可自定义实现来特殊处理。
  4. @BusinessActionContextParameter(isParamInProperty = true),同时paramNamevalue设置了值,那么从对象里读取到map会以paramName为key,添加到context中,而不是以每个属性名为key,属性值为value,逐个设置进去。
    // 警告:此改动,会影响同时使用paramNameisParamInProperty属性的用户。但实际上,原来的功能,设置了isParamInProperty=true后,再设置paramName也是没有意义的(正因为这样使用没有意义,所以才想到扩展这种使用方式)。

    伪代码讲解优化4的变化:

    1. 优化后:actionContext.put(paramName, map)
    2. 优化前:map.forEach((key, value) -> { actionContext.put(key, value); });

@wangliang181230 wangliang181230 changed the title optimize: support instance BusinessActionContext before try method, and @BusinessActionContextParameter(paramName) can not be set optimize: support instance BusinessActionContext before Try method, and @BusinessActionContextParameter(paramName) can not be set May 13, 2021
@wangliang181230 wangliang181230 added this to the 1.5.0 milestone May 13, 2021
@codecov-commenter
Copy link

codecov-commenter commented May 13, 2021

Codecov Report

Merging #3728 (e1f7bb6) into develop (61349de) will decrease coverage by 0.18%.
The diff coverage is 62.29%.

❗ Current head e1f7bb6 differs from pull request most recent head d1e2281. Consider uploading reports for the commit d1e2281 to get more accurate results

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3728      +/-   ##
=============================================
- Coverage      49.42%   49.23%   -0.19%     
+ Complexity      4115     4102      -13     
=============================================
  Files            736      737       +1     
  Lines          25721    25771      +50     
  Branches        3176     3186      +10     
=============================================
- Hits           12713    12689      -24     
- Misses         11662    11729      +67     
- Partials        1346     1353       +7     
Impacted Files Coverage Δ
...a/rm/tcc/interceptor/ActionInterceptorHandler.java 13.97% <36.36%> (+1.93%) ⬆️
...io/seata/rm/tcc/interceptor/ActionContextUtil.java 39.83% <56.75%> (+5.42%) ⬆️
...main/java/io/seata/common/util/ReflectionUtil.java 67.25% <100.00%> (+1.81%) ⬆️
...a/io/seata/rm/tcc/api/DefaultParameterFetcher.java 100.00% <100.00%> (ø)
...va/io/seata/server/console/vo/GlobalSessionVO.java 22.05% <0.00%> (-33.83%) ⬇️
...java/io/seata/server/storage/SessionConverter.java 80.00% <0.00%> (-9.10%) ⬇️
...n/src/main/java/io/seata/common/util/IdWorker.java 77.08% <0.00%> (-6.25%) ⬇️
...rage/redis/store/RedisTransactionStoreManager.java 63.17% <0.00%> (-4.54%) ⬇️
...ta/rm/datasource/exec/AbstractDMLBaseExecutor.java 54.71% <0.00%> (-4.11%) ⬇️
.../rm/datasource/exec/BaseTransactionalExecutor.java 55.26% <0.00%> (-0.66%) ⬇️
... and 2 more

@wangliang181230 wangliang181230 changed the title optimize: support instance BusinessActionContext before Try method, and @BusinessActionContextParameter(paramName) can not be set optimize: support instance BusinessActionContext before Try method, and @BusinessActionContextParameter(paramName) don't need to set it up May 13, 2021
@wangliang181230 wangliang181230 changed the title optimize: support instance BusinessActionContext before Try method, and @BusinessActionContextParameter(paramName) don't need to set it up optimize: support instance BusinessActionContext before Try method, and paramName of @BusinessActionContextParameter becomes optional May 13, 2021
@wangliang181230 wangliang181230 changed the title optimize: Enhance TCC try method and @BusinessActionContextParameter [WIP:#3797] optimize: Enhance TCC try method and @BusinessActionContextParameter Jun 2, 2021
@wangliang181230 wangliang181230 changed the title [WIP:#3797] optimize: Enhance TCC try method and @BusinessActionContextParameter [WIP: after #3797] optimize: Enhance TCC try method and @BusinessActionContextParameter Jun 2, 2021
@wangliang181230 wangliang181230 changed the title [WIP: after #3797] optimize: Enhance TCC try method and @BusinessActionContextParameter [WIP: after #3797] optimize: Enhance TCC annotation @BusinessActionContextParameter Jun 2, 2021
# Conflicts:
#	tcc/src/main/java/io/seata/rm/tcc/api/BusinessActionContextParameter.java
#	tcc/src/main/java/io/seata/rm/tcc/interceptor/ActionContextUtil.java
#	tcc/src/main/java/io/seata/rm/tcc/interceptor/ActionInterceptorHandler.java
…re_1_to_2

# Conflicts:
#	common/src/main/java/io/seata/common/util/ReflectionUtil.java
#	common/src/test/java/io/seata/common/util/ReflectionUtilTest.java
#	tcc/src/main/java/io/seata/rm/tcc/TCCResourceManager.java
#	tcc/src/main/java/io/seata/rm/tcc/api/BusinessActionContextParameter.java
#	tcc/src/main/java/io/seata/rm/tcc/interceptor/ActionContextUtil.java
#	tcc/src/main/java/io/seata/rm/tcc/interceptor/ActionInterceptorHandler.java
#	tcc/src/test/java/io/seata/rm/tcc/TccActionImpl.java
@wangliang181230 wangliang181230 changed the title [WIP: after #3797] optimize: Enhance TCC annotation @BusinessActionContextParameter optimize: Enhance TCC annotation @BusinessActionContextParameter Jul 15, 2021
@funky-eyes funky-eyes modified the milestones: 1.5.0, 2.0.0 Jan 22, 2022
@CLAassistant
Copy link

CLAassistant commented Dec 12, 2022

CLA assistant check
All committers have signed the CLA.

@wangliang181230 wangliang181230 changed the base branch from develop to 2.x January 30, 2023 02:44
@funky-eyes funky-eyes modified the milestones: 2.0.0, 2.x Backlog Nov 4, 2023
@wangliang181230 wangliang181230 marked this pull request as draft November 27, 2023 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mode: TCC TCC transaction mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants