Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
406084b7
Commit
406084b7
authored
May 02, 2019
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加alibaba transmittable-thread-local
parent
0e435533
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
15 deletions
+17
-15
discovery-plugin-strategy-starter-gateway/pom.xml
+5
-0
discovery-plugin-strategy-starter-gateway/src/main/java/com/nepxion/discovery/plugin/strategy/gateway/context/GatewayStrategyContext.java
+3
-1
discovery-plugin-strategy-starter-gateway/src/main/java/com/nepxion/discovery/plugin/strategy/gateway/context/GatewayStrategyContextHolder.java
+2
-14
pom.xml
+7
-0
No files found.
discovery-plugin-strategy-starter-gateway/pom.xml
View file @
406084b7
...
...
@@ -21,6 +21,11 @@
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
transmittable-thread-local
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-gateway
</artifactId>
</dependency>
...
...
discovery-plugin-strategy-starter-gateway/src/main/java/com/nepxion/discovery/plugin/strategy/gateway/context/GatewayStrategyContext.java
View file @
406084b7
...
...
@@ -15,8 +15,10 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
org.springframework.web.server.ServerWebExchange
;
import
com.alibaba.ttl.TransmittableThreadLocal
;
public
class
GatewayStrategyContext
{
private
static
final
ThreadLocal
<
GatewayStrategyContext
>
THREAD_LOCAL
=
new
ThreadLocal
<
GatewayStrategyContext
>()
{
private
static
final
ThreadLocal
<
GatewayStrategyContext
>
THREAD_LOCAL
=
new
T
ransmittableT
hreadLocal
<
GatewayStrategyContext
>()
{
@Override
protected
GatewayStrategyContext
initialValue
()
{
return
new
GatewayStrategyContext
();
...
...
discovery-plugin-strategy-starter-gateway/src/main/java/com/nepxion/discovery/plugin/strategy/gateway/context/GatewayStrategyContextHolder.java
View file @
406084b7
...
...
@@ -9,23 +9,10 @@ package com.nepxion.discovery.plugin.strategy.gateway.context;
* @version 1.0
*/
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.web.server.ServerWebExchange
;
import
com.nepxion.discovery.plugin.strategy.constant.StrategyConstant
;
public
class
GatewayStrategyContextHolder
{
@Autowired
private
ConfigurableEnvironment
environment
;
public
ServerWebExchange
getExchange
()
{
Boolean
hystrixThreadlocalSupported
=
environment
.
getProperty
(
StrategyConstant
.
SPRING_APPLICATION_STRATEGY_HYSTRIX_THREADLOCAL_SUPPORTED
,
Boolean
.
class
,
Boolean
.
FALSE
);
if
(
hystrixThreadlocalSupported
)
{
// 待实现:Spring Cloud Gateway网关端使用Hystrix做线程模式的服务隔离时,实现服务灰度路由的功能
return
GatewayStrategyContext
.
getCurrentContext
().
getExchange
();
}
else
{
return
GatewayStrategyContext
.
getCurrentContext
().
getExchange
();
}
return
GatewayStrategyContext
.
getCurrentContext
().
getExchange
();
}
}
\ No newline at end of file
pom.xml
View file @
406084b7
...
...
@@ -59,6 +59,7 @@
<nacos.version>
1.0.0
</nacos.version>
<guava.version>
27.0-jre
</guava.version>
<caffeine.version>
2.6.2
</caffeine.version>
<transmittable.thread.local.version>
2.10.2
</transmittable.thread.local.version>
<swagger.version>
2.7.0
</swagger.version>
<spring.cloud.version>
Finchley.SR3
</spring.cloud.version>
<spring.cloud.alibaba.version>
0.2.2.RELEASE
</spring.cloud.alibaba.version>
...
...
@@ -281,6 +282,12 @@
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
transmittable-thread-local
</artifactId>
<version>
${transmittable.thread.local.version}
</version>
</dependency>
<dependency>
<groupId>
dom4j
</groupId>
<artifactId>
dom4j
</artifactId>
<version>
${dom4j.version}
</version>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment