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:add seata-spring-boot-starter #1742

Merged
merged 52 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e1debce
support spring-boot auto configuration
xingfudeshi Sep 30, 2019
7ff11ac
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 10, 2019
2889bf6
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 10, 2019
10f3386
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 11, 2019
de28a7d
remove unused imports.
xingfudeshi Oct 11, 2019
fbe225e
Merge remote-tracking branch 'origin/spring-boot-starter' into spring…
xingfudeshi Oct 11, 2019
7f38d25
add missing properties.
xingfudeshi Oct 11, 2019
58e57e7
config missing properties for config&registry
xingfudeshi Oct 11, 2019
a0c7cb2
unify the default port for eureka.
xingfudeshi Oct 11, 2019
e740cbd
code format.
xingfudeshi Oct 11, 2019
6ed3448
extends from parent.
xingfudeshi Oct 11, 2019
0a291e2
set the capacity for HashMap
xingfudeshi Oct 11, 2019
ff693bd
fix coverage
xingfudeshi Oct 11, 2019
7327b91
Revert "extends from parent."
xingfudeshi Oct 11, 2019
7737ec4
fix coverage
xingfudeshi Oct 11, 2019
f6bb843
fix coverage
xingfudeshi Oct 11, 2019
1d3f187
use seata-all
xingfudeshi Oct 11, 2019
2c22e2a
degrades the version of spring-boot 1.5.22.RELEASE
xingfudeshi Oct 11, 2019
a547036
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 11, 2019
9b3b7e0
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 11, 2019
adee8b5
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 11, 2019
5690bdf
Merge branch 'develop' into spring-boot-starter
jsbxyyx Oct 12, 2019
76a97d1
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 12, 2019
8fc0f0c
fix reviews.
xingfudeshi Oct 12, 2019
dd0e5bd
Merge remote-tracking branch 'origin/spring-boot-starter' into spring…
xingfudeshi Oct 12, 2019
980ab95
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 13, 2019
b4429b1
Merge branch 'develop' into spring-boot-starter
jsbxyyx Oct 13, 2019
af35b79
Merge branch 'develop' into spring-boot-starter
jsbxyyx Oct 14, 2019
3bceaaf
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 14, 2019
eb55ee3
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 15, 2019
4acc0e2
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 15, 2019
1bb22f0
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 17, 2019
4ca93bc
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 17, 2019
70e421f
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 18, 2019
10a9c2d
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 19, 2019
c7a1e61
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 21, 2019
005d5a4
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 21, 2019
103bf8f
Merge branch 'develop' into spring-boot-starter
zjinlei Oct 21, 2019
6db8366
Merge branch 'develop' into spring-boot-starter
jsbxyyx Oct 22, 2019
7aa1c59
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 22, 2019
f030d19
fix reviews and add missing configurations.
xingfudeshi Oct 22, 2019
5267c19
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 23, 2019
6953a6c
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 23, 2019
9461671
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 23, 2019
f7512ab
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 23, 2019
5e9cd84
Merge branch 'develop' into spring-boot-starter
zjinlei Oct 24, 2019
efe00ea
update codecov.yml
xingfudeshi Oct 24, 2019
f0ba5b1
Revert "update codecov.yml"
xingfudeshi Oct 24, 2019
eccc6e2
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 24, 2019
f19de4e
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 25, 2019
eda2d62
Merge branch 'develop' into spring-boot-starter
xingfudeshi Oct 25, 2019
59aad16
Merge branch 'develop' into spring-boot-starter
zjinlei Oct 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions codec/seata-codec-seata/src/test/resources/file.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@ service {
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
#disable globaltransaction
disableGlobalTransaction = false
}

client {
async.commit.buffer.limit = 10000
lock {
retry.internal = 10
retry.times = 30
retry.policy.branch-rollback-on-conflict = true
}
report.retry.count = 5
tm.commit.retry.count = 1
tm.rollback.retry.count = 1
#schedule check table meta
table.meta.check.enable = true
}

transaction {
Expand Down
2 changes: 1 addition & 1 deletion codec/seata-codec-seata/src/test/resources/registry.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ registry {
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:1001/eureka"
serviceUrl = "http://localhost:8761/eureka"
application = "default"
weight = "1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,16 @@ public final class ConfigurationFactory {
if (null == envValue) {
envValue = System.getenv(ENV_SYSTEM_KEY);
}
CURRENT_FILE_INSTANCE = (null == envValue) ? new FileConfiguration(seataConfigName + REGISTRY_CONF_SUFFIX)
Configuration configuration = (null == envValue) ? new FileConfiguration(seataConfigName + REGISTRY_CONF_SUFFIX)
: new FileConfiguration(seataConfigName + "-" + envValue + REGISTRY_CONF_SUFFIX);
Configuration extConfiguration = null;
try {
extConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration);

} catch (Exception ignore) {

}
CURRENT_FILE_INSTANCE = null == extConfiguration ? configuration : extConfiguration;
}

private static final String NAME_KEY = "name";
Expand Down Expand Up @@ -91,7 +99,15 @@ private static Configuration buildConfiguration() {
+ FILE_TYPE + ConfigurationKeys.FILE_CONFIG_SPLIT_CHAR
+ NAME_KEY;
String name = CURRENT_FILE_INSTANCE.getConfig(pathDataId);
return new FileConfiguration(name);
Configuration configuration = new FileConfiguration(name);
Configuration extConfiguration = null;
try {
extConfiguration = EnhancedServiceLoader.load(ExtConfigurationProvider.class).provide(configuration);
} catch (Exception ignore) {

}

return null == extConfiguration ? configuration : extConfiguration;
} else {
return EnhancedServiceLoader.load(ConfigurationProvider.class, Objects.requireNonNull(configType).name())
.provide();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.config;

/**
* the interface ext configuration provider
* @author xingfudeshi@gmail.com
* @date 2019/10/03
*/
public interface ExtConfigurationProvider {
/**
* provide a AbstractConfiguration implementation instance
* @param originalConfiguration
* @return configuration
*/
Configuration provide(Configuration originalConfiguration);
}
5 changes: 3 additions & 2 deletions config/seata-config-core/src/main/resources/file.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ service {
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
#disable globaltransaction
disableGlobalTransaction = false
}

client {
async.commit.buffer.limit = 10000
lock {
retry.internal = 10
retry.times = 30
retry.policy.branch-rollback-on-conflict = true
}
report.retry.count = 5
tm.commit.retry.count = 1
Expand Down
2 changes: 1 addition & 1 deletion config/seata-config-core/src/main/resources/registry.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ registry {
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:1001/eureka"
serviceUrl = "http://localhost:8761/eureka"
application = "default"
weight = "1"
}
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<module>tm</module>
<module>metrics</module>
<module>codec</module>
<module>seata-spring-boot-starter</module>
Copy link
Member

Choose a reason for hiding this comment

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

need with seata prefix?

<module>compressor</module>
<module>saga</module>
</modules>
Expand Down
66 changes: 66 additions & 0 deletions seata-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 1999-2019 Seata.io Group.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.seata</groupId>
<artifactId>seata-parent</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>seata-spring-boot-starter</artifactId>
<packaging>jar</packaging>
<name>seata-spring-boot-starter ${project.version}</name>

<properties>
<spring-boot.version>1.5.22.RELEASE</spring-boot.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
zjinlei marked this conversation as resolved.
Show resolved Hide resolved

<dependencies>
<!--seata-->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>seata-all</artifactId>
<version>${project.version}</version>
</dependency>
<!--spring-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.spring.boot.autoconfigure;

import io.seata.rm.datasource.DataSourceProxy;
import io.seata.spring.annotation.GlobalTransactionScanner;
import io.seata.spring.boot.autoconfigure.properties.SeataProperties;
import io.seata.spring.boot.autoconfigure.util.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
* @author xingfudeshi@gmail.com
* @date 2019/09/30
*/
@ComponentScan(basePackages = "io.seata.spring.boot.autoconfigure.properties")
@ConditionalOnProperty(prefix = StarterConstants.SEATA_PREFIX, name = "enabled", matchIfMissing = true)
Copy link
Member

Choose a reason for hiding this comment

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

check seata.enable value.

@ConditionalOnClass({DataSourceProxy.class})
Copy link
Member

Choose a reason for hiding this comment

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

if not contains AT mode.

@Configuration
@EnableConfigurationProperties({SeataProperties.class})
public class SeataAutoConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(SeataAutoConfiguration.class);
@Autowired
private SeataProperties seataProperties;

@Bean
public SpringUtils springUtils() {
return new SpringUtils();
}

@Bean
@DependsOn({"springUtils"})
@ConditionalOnMissingBean(GlobalTransactionScanner.class)
public GlobalTransactionScanner globalTransactionScanner() {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Automatically configure Seata");
}
return new GlobalTransactionScanner(seataProperties.getApplicationId(), seataProperties.getTxServiceGroup());
}


}
Loading