@rdmind/rdmind 0.1.8-alpha.9 → 0.1.9-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +2424 -1884
- package/locales/en.js +93 -192
- package/locales/zh.js +105 -213
- package/package.json +2 -2
- package/template/pom.xml +40 -0
- package/template/sns-demo-app/pom.xml +0 -5
- package/template/sns-demo-common/pom.xml +4 -5
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/constants/AppPlatform.java +57 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/enums/ErrorCodeEnum.java +30 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/exception/AppBizException.java +51 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/utils/AssertUtils.java +137 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/utils/JsonHelper.java +129 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/utils/WrappedContextHelper.java +182 -0
- package/template/sns-demo-domain/pom.xml +0 -5
- package/template/sns-demo-infrastructure/pom.xml +0 -5
- package/template/sns-demo-start/pom.xml +0 -5
- package/template/sns-demo-start/src/main/resources/logback-spring.xml +16 -19
- package/templates/idl-template/wiki/.idea/codeStyles/Project.xml +7 -0
- package/templates/idl-template/wiki/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/templates/idl-template/wiki/.idea/inspectionProfiles/Project_Default.xml +5 -0
- package/templates/idl-template/wiki/.idea/misc.xml +14 -0
- package/templates/idl-template/wiki/.idea/modules.xml +8 -0
- package/templates/idl-template/wiki/.idea/vcs.xml +6 -0
- package/templates/idl-template/wiki/.idea/wiki.iml +9 -0
- package/templates/idl-template/wiki/SDK-Dev-Guide.md +0 -2
- package/templates/idl-template/wiki/example/.gitlab-ci.yml +3 -17
- package/templates/idl-template/wiki/example/base.thrift +94 -0
- package/templates/idl-template/wiki/example/common.thrift +39 -0
- package/templates/idl-template/wiki/example/dto.thrift +3 -0
- package/templates/idl-template/wiki/example/enum.thrift +1 -0
- package/templates/idl-template/wiki/example/gen-java.sh +5 -2
- package/templates/idl-template/wiki/example/maven_project/pom.xml +102 -83
- package/templates/idl-template/wiki/example/req.thrift +4 -0
- package/templates/idl-template/wiki/example/res.thrift +5 -0
- package/templates/idl-template/wiki/example/sdk-spec.yml +4 -3
- package/templates/idl-template/wiki/example/service.thrift +15 -0
- package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/enums/.gitkeep +0 -0
- package/templates/idl-template/wiki/.arcconfig +0 -3
- package/templates/idl-template/wiki/example/.arcconfig +0 -3
- package/templates/idl-template/wiki/example/hello.thrift +0 -29
- package/templates/idl-template/wiki/example/maven_project/src/main/java/com/xiaohongshu/sns/thrift/hello/HelloServiceAutoConfiguration.java +0 -46
- package/templates/idl-template/wiki/example/maven_project/src/main/java/com/xiaohongshu/sns/thrift/hello/HelloServiceProperties.java +0 -18
- package/templates/idl-template/wiki/example/maven_project/src/main/resources/META-INF/spring.factories +0 -3
- package/templates/idl-template/wiki/example/maven_project/src/test/java/com/xiaohongshu/sns/thrift/test/AutoConfigureTest.java +0 -53
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
namespace java com.xiaohongshu.infra.rpc.base
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* rpc context that contains:
|
|
5
|
+
* 1: open tracing infomation
|
|
6
|
+
* 2: userID for log coloring
|
|
7
|
+
* 3: an expandable map for custom loads
|
|
8
|
+
*/
|
|
9
|
+
struct Context {
|
|
10
|
+
/**
|
|
11
|
+
* open tracing trace id
|
|
12
|
+
**/
|
|
13
|
+
1: string traceID;
|
|
14
|
+
/**
|
|
15
|
+
* the caller's host (IP or hostname)
|
|
16
|
+
**/
|
|
17
|
+
2: string clientHost;
|
|
18
|
+
/**
|
|
19
|
+
* open tracing baggae, can be used to carry custom loads
|
|
20
|
+
**/
|
|
21
|
+
3: map<string, string> baggage;
|
|
22
|
+
/**
|
|
23
|
+
* open tracing span id
|
|
24
|
+
**/
|
|
25
|
+
4: string spanID;
|
|
26
|
+
/**
|
|
27
|
+
* whether the very request is sampled
|
|
28
|
+
**/
|
|
29
|
+
5: bool sampled;
|
|
30
|
+
/**
|
|
31
|
+
* open tracing parent span ID
|
|
32
|
+
**/
|
|
33
|
+
6: string parentSpanID;
|
|
34
|
+
/**
|
|
35
|
+
* userID for log coloring
|
|
36
|
+
**/
|
|
37
|
+
7: string userID;
|
|
38
|
+
/**
|
|
39
|
+
* appID for multi-app
|
|
40
|
+
**/
|
|
41
|
+
8: string appID;
|
|
42
|
+
/**
|
|
43
|
+
* projectID for multi-app
|
|
44
|
+
**/
|
|
45
|
+
9: string projectID;
|
|
46
|
+
/**
|
|
47
|
+
* app build number
|
|
48
|
+
**/
|
|
49
|
+
10: i32 appBuild;
|
|
50
|
+
/**
|
|
51
|
+
* app platform
|
|
52
|
+
**/
|
|
53
|
+
11: string appPlatform;
|
|
54
|
+
/**
|
|
55
|
+
* user ip address
|
|
56
|
+
**/
|
|
57
|
+
12: string userIP;
|
|
58
|
+
/**
|
|
59
|
+
* session locale
|
|
60
|
+
**/
|
|
61
|
+
13: string locale;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* multi-app 枚举类型
|
|
66
|
+
**/
|
|
67
|
+
enum ProjectType {
|
|
68
|
+
XHS = 0
|
|
69
|
+
TOP = 1
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* common result
|
|
74
|
+
*/
|
|
75
|
+
struct Result {
|
|
76
|
+
1: required bool success,
|
|
77
|
+
2: optional i32 code,
|
|
78
|
+
3: optional string message
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* typedefs
|
|
83
|
+
*/
|
|
84
|
+
typedef i64 Timestamp
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* the BaseService is defined for management purpose, such as check alive.
|
|
88
|
+
**/
|
|
89
|
+
service BaseService {
|
|
90
|
+
/**
|
|
91
|
+
* for checking alive
|
|
92
|
+
**/
|
|
93
|
+
void ping()
|
|
94
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
namespace java com.xiaohongshu.sns.demo.api.common
|
|
2
|
+
|
|
3
|
+
include "../base/base.thrift"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 分页-请求对象
|
|
7
|
+
**/
|
|
8
|
+
struct PageParam {
|
|
9
|
+
/**
|
|
10
|
+
* 页码
|
|
11
|
+
**/
|
|
12
|
+
1:optional i32 pageNo;
|
|
13
|
+
/**
|
|
14
|
+
* 分页大小
|
|
15
|
+
**/
|
|
16
|
+
2:optional i32 pageSize;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 分页-返回对象
|
|
21
|
+
**/
|
|
22
|
+
struct PageResp {
|
|
23
|
+
/**
|
|
24
|
+
* 当前页
|
|
25
|
+
**/
|
|
26
|
+
1:optional i32 currentPage;
|
|
27
|
+
/**
|
|
28
|
+
* 分页大小
|
|
29
|
+
**/
|
|
30
|
+
2:optional i32 pageSize;
|
|
31
|
+
/**
|
|
32
|
+
* 总页数
|
|
33
|
+
**/
|
|
34
|
+
3:optional i32 totalPages;
|
|
35
|
+
/**
|
|
36
|
+
* 总条数
|
|
37
|
+
**/
|
|
38
|
+
4:optional i32 totalCount;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
namespace java com.xiaohongshu.sns.demo.api.enum
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
thrift
|
|
3
|
+
# 这里每一行就是一个thrift文件路径,直接遍历来快速构建
|
|
4
|
+
filename="./service.thrift"
|
|
5
|
+
for file in $filename; do
|
|
6
|
+
thrift --gen java:generated_annotations=undated -out maven_project/src/main/java/ $file
|
|
7
|
+
done
|
|
@@ -1,95 +1,114 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
1
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
3
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
|
4
|
+
<modelVersion>4.0.0</modelVersion>
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<version>${sdk.version}</version>
|
|
6
|
+
<groupId>com.xiaohongshu.sns</groupId>
|
|
7
|
+
<artifactId>demo-api</artifactId>
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<sdk.version>1.0.0-SNAPSHOT</sdk.version>
|
|
14
|
-
<midware.version>2.2.31-RELEASE</midware.version>
|
|
15
|
-
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
|
|
16
|
-
</properties>
|
|
9
|
+
<!-- 无须动,ci的时候会自动覆盖的 -->
|
|
10
|
+
<version>${sdk.version}</version>
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
</configuration>
|
|
27
|
-
</plugin>
|
|
28
|
-
<plugin>
|
|
29
|
-
<groupId>org.apache.maven.plugins</groupId>
|
|
30
|
-
<artifactId>maven-surefire-plugin</artifactId>
|
|
31
|
-
<configuration>
|
|
32
|
-
<skip>true</skip>
|
|
33
|
-
</configuration>
|
|
34
|
-
</plugin>
|
|
35
|
-
</plugins>
|
|
36
|
-
</build>
|
|
37
|
-
|
|
38
|
-
<dependencyManagement>
|
|
39
|
-
<dependencies>
|
|
40
|
-
<dependency>
|
|
41
|
-
<groupId>com.xiaohongshu</groupId>
|
|
42
|
-
<artifactId>midware-dependencies</artifactId>
|
|
43
|
-
<version>${midware.version}</version>
|
|
44
|
-
<type>pom</type>
|
|
45
|
-
<scope>import</scope>
|
|
46
|
-
</dependency>
|
|
47
|
-
<dependency>
|
|
48
|
-
<groupId>org.springframework.boot</groupId>
|
|
49
|
-
<artifactId>spring-boot-dependencies</artifactId>
|
|
50
|
-
<version>${spring-boot.version}</version>
|
|
51
|
-
<type>pom</type>
|
|
52
|
-
<scope>import</scope>
|
|
53
|
-
</dependency>
|
|
54
|
-
</dependencies>
|
|
55
|
-
</dependencyManagement>
|
|
12
|
+
<properties>
|
|
13
|
+
<midware.version>3.3.11-RELEASE</midware.version>
|
|
14
|
+
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
|
|
15
|
+
<!--这里换成jdk11 david解析不了,不支持-->
|
|
16
|
+
<maven.compiler.source>8</maven.compiler.source>
|
|
17
|
+
<maven.compiler.target>8</maven.compiler.target>
|
|
18
|
+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
19
|
+
</properties>
|
|
56
20
|
|
|
21
|
+
<dependencyManagement>
|
|
57
22
|
<dependencies>
|
|
23
|
+
<dependency>
|
|
24
|
+
<groupId>com.xiaohongshu</groupId>
|
|
25
|
+
<artifactId>midware-dependencies</artifactId>
|
|
26
|
+
<version>${midware.version}</version>
|
|
27
|
+
<type>pom</type>
|
|
28
|
+
<scope>import</scope>
|
|
29
|
+
</dependency>
|
|
30
|
+
<dependency>
|
|
31
|
+
<groupId>org.springframework.boot</groupId>
|
|
32
|
+
<artifactId>spring-boot-dependencies</artifactId>
|
|
33
|
+
<version>${spring-boot.version}</version>
|
|
34
|
+
<type>pom</type>
|
|
35
|
+
<scope>import</scope>
|
|
36
|
+
</dependency>
|
|
58
37
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<artifactId>thrift-springboot</artifactId>
|
|
62
|
-
</dependency>
|
|
38
|
+
</dependencies>
|
|
39
|
+
</dependencyManagement>
|
|
63
40
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
41
|
+
<dependencies>
|
|
42
|
+
<dependency>
|
|
43
|
+
<groupId>com.xiaohongshu</groupId>
|
|
44
|
+
<artifactId>rpc-context</artifactId>
|
|
45
|
+
</dependency>
|
|
68
46
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
47
|
+
<dependency>
|
|
48
|
+
<groupId>com.xiaohongshu</groupId>
|
|
49
|
+
<artifactId>thrift-springboot</artifactId>
|
|
50
|
+
<optional>true</optional>
|
|
51
|
+
</dependency>
|
|
74
52
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
53
|
+
<dependency>
|
|
54
|
+
<groupId>org.springframework.boot</groupId>
|
|
55
|
+
<artifactId>spring-boot-autoconfigure</artifactId>
|
|
56
|
+
<optional>true</optional>
|
|
57
|
+
</dependency>
|
|
58
|
+
|
|
59
|
+
<dependency>
|
|
60
|
+
<groupId>org.apache.thrift</groupId>
|
|
61
|
+
<artifactId>libthrift</artifactId>
|
|
62
|
+
</dependency>
|
|
63
|
+
|
|
64
|
+
<dependency>
|
|
65
|
+
<groupId>org.springframework.boot</groupId>
|
|
66
|
+
<artifactId>spring-boot-configuration-processor</artifactId>
|
|
67
|
+
<optional>true</optional>
|
|
68
|
+
</dependency>
|
|
81
69
|
|
|
82
|
-
|
|
83
|
-
<snapshotRepository>
|
|
84
|
-
<id>snapshots</id>
|
|
85
|
-
<name>maven snapshot repository</name>
|
|
86
|
-
<url>https://artifactory.devops.xiaohongshu.com/artifactory/maven-snapshots/</url>
|
|
87
|
-
</snapshotRepository>
|
|
88
|
-
<repository>
|
|
89
|
-
<id>releases</id>
|
|
90
|
-
<name>maven releases repository</name>
|
|
91
|
-
<url>https://artifactory.devops.xiaohongshu.com/artifactory/maven-releases/</url>
|
|
92
|
-
</repository>
|
|
93
|
-
</distributionManagement>
|
|
70
|
+
</dependencies>
|
|
94
71
|
|
|
95
|
-
|
|
72
|
+
<build>
|
|
73
|
+
<plugins>
|
|
74
|
+
<plugin>
|
|
75
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
76
|
+
<artifactId>maven-compiler-plugin</artifactId>
|
|
77
|
+
<version>3.8.1</version>
|
|
78
|
+
<configuration>
|
|
79
|
+
<source>1.8</source>
|
|
80
|
+
<target>1.8</target>
|
|
81
|
+
</configuration>
|
|
82
|
+
</plugin>
|
|
83
|
+
<plugin>
|
|
84
|
+
<groupId>org.apache.maven.plugins</groupId>
|
|
85
|
+
<artifactId>maven-source-plugin</artifactId>
|
|
86
|
+
<version>2.1.1</version>
|
|
87
|
+
<executions>
|
|
88
|
+
<execution>
|
|
89
|
+
<id>attach-sources</id>
|
|
90
|
+
<goals>
|
|
91
|
+
<goal>jar-no-fork</goal>
|
|
92
|
+
</goals>
|
|
93
|
+
</execution>
|
|
94
|
+
</executions>
|
|
95
|
+
</plugin>
|
|
96
|
+
</plugins>
|
|
97
|
+
</build>
|
|
98
|
+
<distributionManagement>
|
|
99
|
+
<snapshotRepository>
|
|
100
|
+
<id>snapshots</id>
|
|
101
|
+
<name>nexus snapshot repository</name>
|
|
102
|
+
<url>
|
|
103
|
+
https://artifactory.devops.xiaohongshu.com/artifactory/maven-snapshots/
|
|
104
|
+
</url>
|
|
105
|
+
</snapshotRepository>
|
|
106
|
+
<repository>
|
|
107
|
+
<id>releases</id>
|
|
108
|
+
<name>nexus repository</name>
|
|
109
|
+
<url>
|
|
110
|
+
https://artifactory.devops.xiaohongshu.com/artifactory/maven-releases/
|
|
111
|
+
</url>
|
|
112
|
+
</repository>
|
|
113
|
+
</distributionManagement>
|
|
114
|
+
</project>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
dependencies:
|
|
2
|
-
sns-idls/base: 1.
|
|
2
|
+
sns-idls/base: 1.1.7 # 依赖sns-idls/base项目,tag为1.1.7
|
|
3
3
|
build:
|
|
4
|
-
|
|
5
|
-
enabled: false
|
|
4
|
+
go:
|
|
5
|
+
enabled: false # 是否开启go编译 [gosdk](https://wiki.xiaohongshu.com/pages/viewpage.action?pageId=43487207)
|
|
6
|
+
recurse: true # 是否递归编译引用的thrift文件(默认会将com.xiaohongshu.infra.rpc.base包删除)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
namespace java com.xiaohongshu.sns.demo.api.service
|
|
2
|
+
|
|
3
|
+
include "../base/base.thrift"
|
|
4
|
+
include "./req.thrift"
|
|
5
|
+
include "./res.thrift"
|
|
6
|
+
include "./common.thrift"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 第一个参数约定传base.Context,请求打点使用。
|
|
10
|
+
* base.BaseService接口继承ping方法,健康检查使用
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/enums/.gitkeep
DELETED
|
File without changes
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
namespace java com.xiaohongshu.sns.rpc.hello
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
base.thrift 文件路径不要修改,打包过程会默认加入
|
|
5
|
-
具体文件格式可以参看
|
|
6
|
-
<groupId>com.xiaohongshu</groupId>
|
|
7
|
-
<artifactId>thrift-rpc</artifactId>
|
|
8
|
-
*/
|
|
9
|
-
include "../base/base.thrift"
|
|
10
|
-
|
|
11
|
-
struct HelloRequest{
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
struct HelloResponse{
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/*
|
|
20
|
-
第一个参数约定传base.Context,请求打点使用。
|
|
21
|
-
base.BaseService接口继承ping方法,健康检查使用
|
|
22
|
-
*/
|
|
23
|
-
service HelloService extends base.BaseService {
|
|
24
|
-
|
|
25
|
-
HelloResponse sayHello(
|
|
26
|
-
1: base.Context context
|
|
27
|
-
2: HelloRequest request
|
|
28
|
-
)
|
|
29
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
package com.xiaohongshu.sns.thrift.hello;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import com.xiaohongshu.infra.rpc.core.client.NettyClientProxyFactory;
|
|
5
|
-
import com.xiaohongshu.infra.rpc.core.registry.eds.MultiRegionsEdsThriftAddressSubscriberProvider;
|
|
6
|
-
import com.xiaohongshu.sns.rpc.hello.HelloService;
|
|
7
|
-
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
|
8
|
-
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
9
|
-
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
10
|
-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
11
|
-
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
12
|
-
import org.springframework.context.annotation.Bean;
|
|
13
|
-
import org.springframework.context.annotation.Configuration;
|
|
14
|
-
import org.springframework.context.annotation.Lazy;
|
|
15
|
-
|
|
16
|
-
@Configuration
|
|
17
|
-
@ConditionalOnProperty(prefix = "rpc.hello", name = "service-name")
|
|
18
|
-
@ConditionalOnClass(HelloService.class)
|
|
19
|
-
@ConditionalOnBean(MultiRegionsEdsThriftAddressSubscriberProvider.class)
|
|
20
|
-
@EnableConfigurationProperties(com.xiaohongshu.sns.thrift.hello.HelloServiceProperties.class)
|
|
21
|
-
public class HelloServiceAutoConfiguration {
|
|
22
|
-
|
|
23
|
-
private MultiRegionsEdsThriftAddressSubscriberProvider thriftServerMultiRegionEdsSubscriber;
|
|
24
|
-
private com.xiaohongshu.sns.thrift.hello.HelloServiceProperties properties;
|
|
25
|
-
|
|
26
|
-
public HelloServiceAutoConfiguration (MultiRegionsEdsThriftAddressSubscriberProvider thriftServerMultiRegionEdsSubscriber,
|
|
27
|
-
com.xiaohongshu.sns.thrift.hello.HelloServiceProperties properties) {
|
|
28
|
-
this.thriftServerMultiRegionEdsSubscriber = thriftServerMultiRegionEdsSubscriber;
|
|
29
|
-
this.properties = properties;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@Lazy
|
|
33
|
-
@Bean
|
|
34
|
-
@ConditionalOnMissingBean(name = "helloClient")
|
|
35
|
-
public NettyClientProxyFactory helloClient() {
|
|
36
|
-
NettyClientProxyFactory factory = new NettyClientProxyFactory();
|
|
37
|
-
factory.setServerAddressProvider(this.thriftServerMultiRegionEdsSubscriber);
|
|
38
|
-
factory.setThriftClass(HelloService.class);
|
|
39
|
-
factory.setServiceName(this.properties.getServiceName());
|
|
40
|
-
factory.setRpcTimeout(this.properties.getRpcTimeout());
|
|
41
|
-
factory.setConnectTimeout(this.properties.getConnectionTimeout());
|
|
42
|
-
factory.setMethodConfigMap(this.properties.getMethodConfig());
|
|
43
|
-
return factory;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
package com.xiaohongshu.sns.thrift.hello;
|
|
2
|
-
|
|
3
|
-
import com.xiaohongshu.infra.rpc.core.ThriftMethodConfig;
|
|
4
|
-
import lombok.Data;
|
|
5
|
-
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
6
|
-
|
|
7
|
-
import java.util.Map;
|
|
8
|
-
|
|
9
|
-
@Data
|
|
10
|
-
@ConfigurationProperties("rpc.hello")
|
|
11
|
-
public class HelloServiceProperties {
|
|
12
|
-
|
|
13
|
-
private String serviceName;
|
|
14
|
-
private Integer rpcTimeout = 1000;
|
|
15
|
-
private Integer connectionTimeout = 100;
|
|
16
|
-
private Map<String, ThriftMethodConfig> methodConfig;
|
|
17
|
-
|
|
18
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
package com.xiaohongshu.sns.thrift.test;
|
|
2
|
-
|
|
3
|
-
import com.xiaohongshu.infra.rpc.core.registry.consul.ThriftServerAddressConsulManager;
|
|
4
|
-
import com.xiaohongshu.sns.rpc.hello.HelloService;
|
|
5
|
-
import com.xiaohongshu.sns.thrift.hello.HelloServiceAutoConfiguration;
|
|
6
|
-
import org.junit.After;
|
|
7
|
-
import org.junit.Assert;
|
|
8
|
-
import org.junit.Before;
|
|
9
|
-
import org.junit.Test;
|
|
10
|
-
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|
11
|
-
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
12
|
-
import org.springframework.core.env.MutablePropertySources;
|
|
13
|
-
import org.springframework.core.env.StandardEnvironment;
|
|
14
|
-
import org.springframework.mock.env.MockPropertySource;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
public class AutoConfigureTest {
|
|
18
|
-
|
|
19
|
-
private AnnotationConfigApplicationContext context;
|
|
20
|
-
|
|
21
|
-
@Before
|
|
22
|
-
public void setUp() {
|
|
23
|
-
this.context = new AnnotationConfigApplicationContext();
|
|
24
|
-
StandardEnvironment environment = new StandardEnvironment();
|
|
25
|
-
MutablePropertySources propertySources = environment.getPropertySources();
|
|
26
|
-
MockPropertySource propertySource = new MockPropertySource();
|
|
27
|
-
propertySource.setProperty("rpc.hello.serviceName", "xxx");
|
|
28
|
-
propertySources.addFirst(propertySource);
|
|
29
|
-
context.setEnvironment(environment);
|
|
30
|
-
context.register(ThriftServerAddressConsulManager.class);
|
|
31
|
-
context.register(HelloServiceAutoConfiguration.class);
|
|
32
|
-
context.refresh();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@After
|
|
36
|
-
public void tearDown() {
|
|
37
|
-
if (this.context != null) {
|
|
38
|
-
this.context.close();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Test
|
|
43
|
-
public void testBeanRegistration() {
|
|
44
|
-
try {
|
|
45
|
-
HelloService.Iface client = this.context.getBean("helloClient", HelloService.Iface.class);
|
|
46
|
-
client.ping();
|
|
47
|
-
} catch (NoSuchBeanDefinitionException e) {
|
|
48
|
-
Assert.fail(e.getMessage());
|
|
49
|
-
} catch (Exception e) {
|
|
50
|
-
e.printStackTrace();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|