apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.25k stars 8.77k forks source link

feature: add single server rale limit #6756

Open xjlgod opened 1 month ago

xjlgod commented 1 month ago

Ⅰ. Describe what this PR did

Support flow limiting control for a single server:

Ⅱ. 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[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 46.74556% with 90 lines in your changes missing coverage. Please review.

Project coverage is 52.27%. Comparing base (9263976) to head (c01b24f). Report is 3 commits behind head on 2.x.

Files with missing lines Patch % Lines
...va/org/apache/seata/core/event/RateLimitEvent.java 0.00% 23 Missing :warning:
...che/seata/server/ratelimit/TokenBucketLimiter.java 45.71% 19 Missing :warning:
...e/properties/server/ServerRateLimitProperties.java 7.69% 12 Missing :warning:
...e/seata/server/coordinator/DefaultCoordinator.java 9.09% 9 Missing and 1 partial :warning:
...che/seata/server/ratelimit/RateLimiterHandler.java 56.52% 9 Missing and 1 partial :warning:
...handler/GlobalTransactionalInterceptorHandler.java 0.00% 3 Missing :warning:
...ava/io/seata/tm/api/DefaultFailureHandlerImpl.java 0.00% 2 Missing :warning:
...ga/engine/tm/DefaultSagaTransactionalTemplate.java 0.00% 2 Missing :warning:
...zer/seata/protocol/AbstractResultMessageCodec.java 0.00% 0 Missing and 2 partials :warning:
...org/apache/seata/tm/DefaultTransactionManager.java 0.00% 2 Missing :warning:
... and 3 more
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/apache/incubator-seata/pull/6756/graphs/tree.svg?width=650&height=150&src=pr&token=tbmHt2ZfxO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) ```diff @@ Coverage Diff @@ ## 2.x #6756 +/- ## ============================================ - Coverage 52.31% 52.27% -0.04% - Complexity 6375 6394 +19 ============================================ Files 1078 1083 +5 Lines 37483 37648 +165 Branches 4440 4451 +11 ============================================ + Hits 19608 19681 +73 - Misses 15938 16026 +88 - Partials 1937 1941 +4 ``` | [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | |---|---|---| | [...ava/org/apache/seata/common/ConfigurationKeys.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcommon%2FConfigurationKeys.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9jb21tb24vQ29uZmlndXJhdGlvbktleXMuamF2YQ==) | `0.00% <ø> (ø)` | | | [...seata/core/exception/TransactionExceptionCode.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Fexception%2FTransactionExceptionCode.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9leGNlcHRpb24vVHJhbnNhY3Rpb25FeGNlcHRpb25Db2RlLmphdmE=) | `100.00% <100.00%> (ø)` | | | [...ava/org/apache/seata/core/protocol/ResultCode.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fcore%2Fprotocol%2FResultCode.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvY29yZS9wcm90b2NvbC9SZXN1bHRDb2RlLmphdmE=) | `100.00% <100.00%> (ø)` | | | [...ta/spring/boot/autoconfigure/StarterConstants.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=seata-spring-autoconfigure%2Fseata-spring-autoconfigure-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fspring%2Fboot%2Fautoconfigure%2FStarterConstants.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VhdGEtc3ByaW5nLWF1dG9jb25maWd1cmUvc2VhdGEtc3ByaW5nLWF1dG9jb25maWd1cmUtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VhdGEvc3ByaW5nL2Jvb3QvYXV0b2NvbmZpZ3VyZS9TdGFydGVyQ29uc3RhbnRzLmphdmE=) | `100.00% <ø> (ø)` | | | [.../apache/seata/server/metrics/MeterIdConstants.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=server%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fserver%2Fmetrics%2FMeterIdConstants.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9zZXJ2ZXIvbWV0cmljcy9NZXRlcklkQ29uc3RhbnRzLmphdmE=) | `100.00% <100.00%> (ø)` | | | [.../apache/seata/server/metrics/MetricsPublisher.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=server%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fserver%2Fmetrics%2FMetricsPublisher.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9zZXJ2ZXIvbWV0cmljcy9NZXRyaWNzUHVibGlzaGVyLmphdmE=) | `94.73% <100.00%> (+0.98%)` | :arrow_up: | | [...apache/seata/server/metrics/MetricsSubscriber.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=server%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fserver%2Fmetrics%2FMetricsSubscriber.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9zZXJ2ZXIvbWV0cmljcy9NZXRyaWNzU3Vic2NyaWJlci5qYXZh) | `21.70% <100.00%> (+7.29%)` | :arrow_up: | | [...g/apache/seata/server/ratelimit/RateLimitInfo.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=server%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fserver%2Fratelimit%2FRateLimitInfo.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9zZXJ2ZXIvcmF0ZWxpbWl0L1JhdGVMaW1pdEluZm8uamF2YQ==) | `100.00% <100.00%> (ø)` | | | [...org/apache/seata/tm/api/TransactionalExecutor.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=tm%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Ftm%2Fapi%2FTransactionalExecutor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-dG0vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NlYXRhL3RtL2FwaS9UcmFuc2FjdGlvbmFsRXhlY3V0b3IuamF2YQ==) | `65.51% <100.00%> (+1.23%)` | :arrow_up: | | [...configure/SeataServerEnvironmentPostProcessor.java](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree&filepath=seata-spring-autoconfigure%2Fseata-spring-autoconfigure-server%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fseata%2Fspring%2Fboot%2Fautoconfigure%2FSeataServerEnvironmentPostProcessor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VhdGEtc3ByaW5nLWF1dG9jb25maWd1cmUvc2VhdGEtc3ByaW5nLWF1dG9jb25maWd1cmUtc2VydmVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZWF0YS9zcHJpbmcvYm9vdC9hdXRvY29uZmlndXJlL1NlYXRhU2VydmVyRW52aXJvbm1lbnRQb3N0UHJvY2Vzc29yLmphdmE=) | `0.00% <0.00%> (ø)` | | | ... and [12 more](https://app.codecov.io/gh/apache/incubator-seata/pull/6756?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | ... and [4 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/6756/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)