@rdmind/rdmind 0.0.21-alpha.2 → 0.0.22-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.
Files changed (29) hide show
  1. package/cli.js +4489 -3452
  2. package/package.json +2 -2
  3. package/template/sns-demo-app/pom.xml +5 -0
  4. package/template/sns-demo-app/src/test/java/com/xiaohongshu/sns/demo/app/.gitkeep +0 -0
  5. package/template/sns-demo-common/pom.xml +9 -0
  6. package/template/sns-demo-common/src/main/java/com/xiaohongshu/sns/demo/common/metrics/DemoMetrics.java +83 -0
  7. package/template/sns-demo-common/src/test/java/com/xiaohongshu/sns/demo/common/.gitkeep +0 -0
  8. package/template/sns-demo-common/src/test/java/com/xiaohongshu/sns/demo/common/utils/RpcResultUtilsTest.java +29 -0
  9. package/template/sns-demo-domain/pom.xml +5 -0
  10. package/template/sns-demo-domain/src/test/java/com/xiaohongshu/sns/demo/domain/.gitkeep +0 -0
  11. package/template/sns-demo-infrastructure/pom.xml +5 -0
  12. package/template/sns-demo-infrastructure/src/main/java/com/xiaohongshu/sns/demo/infrastructure/config/threadpool/ExecutorConfig.java +24 -0
  13. package/template/sns-demo-infrastructure/src/test/java/com/xiaohongshu/sns/demo/infrastructure/.gitkeep +0 -0
  14. package/template/sns-demo-start/pom.xml +5 -0
  15. package/template/sns-demo-start/src/test/java/com/xiaohongshu/sns/demo/start/.gitkeep +0 -0
  16. package/templates/idl-template/wiki/.arcconfig +3 -0
  17. package/templates/idl-template/wiki/README.md +173 -0
  18. package/templates/idl-template/wiki/SDK-Dev-Guide.md +61 -0
  19. package/templates/idl-template/wiki/example/.arcconfig +3 -0
  20. package/templates/idl-template/wiki/example/.gitlab-ci.yml +26 -0
  21. package/templates/idl-template/wiki/example/gen-java.sh +4 -0
  22. package/templates/idl-template/wiki/example/hello.thrift +29 -0
  23. package/templates/idl-template/wiki/example/maven_project/pom.xml +95 -0
  24. package/templates/idl-template/wiki/example/maven_project/src/main/java/com/xiaohongshu/sns/thrift/hello/HelloServiceAutoConfiguration.java +46 -0
  25. package/templates/idl-template/wiki/example/maven_project/src/main/java/com/xiaohongshu/sns/thrift/hello/HelloServiceProperties.java +18 -0
  26. package/templates/idl-template/wiki/example/maven_project/src/main/resources/META-INF/spring.factories +3 -0
  27. package/templates/idl-template/wiki/example/maven_project/src/test/java/com/xiaohongshu/sns/thrift/test/AutoConfigureTest.java +53 -0
  28. package/templates/idl-template/wiki/example/sdk-spec.yml +5 -0
  29. package/examples/context/RDMind.md +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdmind/rdmind",
3
- "version": "0.0.21-alpha.2",
3
+ "version": "0.0.22-alpha.0",
4
4
  "description": "RDMind - AI-powered coding assistant",
5
5
  "type": "module",
6
6
  "main": "cli.js",
@@ -19,7 +19,7 @@
19
19
  "LICENSE"
20
20
  ],
21
21
  "config": {
22
- "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.0.21-alpha.2"
22
+ "sandboxImageUri": "ghcr.io/qwenlm/qwen-code:0.0.22-alpha.0"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"
@@ -22,6 +22,11 @@
22
22
  <groupId>com.xiaohongshu.sns</groupId>
23
23
  <artifactId>sns-demo-infrastructure</artifactId>
24
24
  </dependency>
25
+ <dependency>
26
+ <groupId>org.springframework.boot</groupId>
27
+ <artifactId>spring-boot-starter-test</artifactId>
28
+ <scope>test</scope>
29
+ </dependency>
25
30
  </dependencies>
26
31
 
27
32
  </project>
@@ -30,6 +30,15 @@
30
30
  <groupId>org.projectlombok</groupId>
31
31
  <artifactId>lombok</artifactId>
32
32
  </dependency>
33
+ <dependency>
34
+ <groupId>com.xiaohongshu</groupId>
35
+ <artifactId>events-client</artifactId>
36
+ </dependency>
37
+ <dependency>
38
+ <groupId>org.springframework.boot</groupId>
39
+ <artifactId>spring-boot-starter-test</artifactId>
40
+ <scope>test</scope>
41
+ </dependency>
33
42
  </dependencies>
34
43
 
35
44
  </project>
@@ -0,0 +1,83 @@
1
+ package com.xiaohongshu.sns.demo.common.metrics;
2
+
3
+ import com.dianping.cat.Cat;
4
+
5
+ import java.util.concurrent.TimeUnit;
6
+
7
+ /**
8
+ * 指标打点 Demo
9
+ * <p>
10
+ * 参考 <a href="https://xray-doc.devops.xiaohongshu.com/docs/metric/prometheus-integration-new.html">CAT 集成 Prometheus(新版)</a>
11
+ */
12
+ public class DemoMetrics {
13
+
14
+ /**
15
+ * Counter 用于持续递增的度量值,如网站访问次数,API 调用次数/QPS,对于业务系统而言比如订单数等,常搭配 increase()、rate() 函数使用
16
+ */
17
+ public static void counter() {
18
+ Cat.counter("collection_number_total", "收款总笔数")
19
+ .addTag("channel", "channel_1")
20
+ .addTag("status", "true")
21
+ .increment(10);
22
+ }
23
+
24
+
25
+ /**
26
+ * Gauge 用于记录指标原始值,侧重于反应系统当前的状态,这类指标的样本数据可增可减。如系统中的线程数、CPU 使用率、内存使用率等
27
+ */
28
+ public static void gauge() {
29
+ Cat.gauge("paying_timeout", "付款超时")
30
+ .addTag("channel", "channel_1")
31
+ .addTag("status", "true")
32
+ .setValue(1);
33
+ }
34
+
35
+ /**
36
+ * Summary 用于记录样本数据的分布情况,如响应时间、RPC 调用耗时等
37
+ * Summary 一般会生成三种指标:分位值快照、总量、次数,其中分位值快照用于 Prometheus 的分位值查询,总量和次数用于计算平均值。
38
+ */
39
+ public static void summary() {
40
+ // 不带分位值统计
41
+ Cat.summary("rpc_calls", "RPC调用详情")
42
+ .addTag("endpoint", "endpoint_1")
43
+ .addTag("success", "true")
44
+ .record(15.0);
45
+
46
+ // 带分位值统计
47
+ Cat.summary("rpc_calls", "RPC调用详情")
48
+ .addTag("endpoint", "endpoint_1")
49
+ .addTag("success", "true")
50
+ .publishPercentiles(0.95, 0.99)
51
+ .record(15.0);
52
+
53
+ // 默认分位值 95/99/999
54
+ Cat.summary("rpc_calls", "RPC调用详情")
55
+ .addTag("endpoint", "endpoint_1")
56
+ .addTag("success", "true")
57
+ .publishDefaultPercentiles()
58
+ .record(15.0);
59
+ }
60
+
61
+ /**
62
+ * 类似于 Summary,Timer 用于测量短时间内的持续时间,以及跟踪这些测量的频率。它通常用于测量如 HTTP 请求响应时间等操作的时间。
63
+ * Timer 一般会生成四种指标:分位值快照、总量、次数、最大值,其中分位值快照用于 Prometheus 的分位值查询,总量和次数用于计算平均值。
64
+ */
65
+ public static void timer() throws InterruptedException {
66
+ // 不带分位值统计
67
+ Cat.timer("http_request_duration", "HTTP调用耗时")
68
+ .addTag("endpoint", "endpoint_1")
69
+ .record(300, TimeUnit.MILLISECONDS);
70
+
71
+ // 带分位值统计
72
+ Cat.timer("http_request_duration", "HTTP调用耗时")
73
+ .addTag("endpoint", "endpoint_1")
74
+ .publishPercentiles(0.95, 0.99)
75
+ .record(300, TimeUnit.MILLISECONDS);
76
+
77
+ // 默认分位值 95/99/999
78
+ Cat.timer("http_request_duration", "HTTP调用耗时")
79
+ .addTag("endpoint", "endpoint_1")
80
+ .publishDefaultPercentiles()
81
+ .record(300, TimeUnit.MILLISECONDS);
82
+ }
83
+ }
@@ -0,0 +1,29 @@
1
+ package com.xiaohongshu.sns.demo.common.utils;
2
+
3
+ import com.xiaohongshu.infra.rpc.base.Result;
4
+ import org.junit.Test;
5
+ import static org.junit.Assert.*;
6
+
7
+ public class RpcResultUtilsTest {
8
+
9
+ @Test
10
+ public void success() {
11
+ Result result = RpcResultUtils.success();
12
+
13
+ assertNotNull(result);
14
+ assertTrue(result.isSuccess());
15
+ assertEquals(0, result.getCode());
16
+ assertEquals("success", result.getMessage());
17
+ }
18
+
19
+ @Test
20
+ public void failed() {
21
+ String errorMsg = "test error";
22
+ Result result = RpcResultUtils.failed(errorMsg);
23
+
24
+ assertNotNull(result);
25
+ assertFalse(result.isSuccess());
26
+ assertEquals(-1, result.getCode());
27
+ assertEquals(errorMsg, result.getMessage());
28
+ }
29
+ }
@@ -26,6 +26,11 @@
26
26
  <groupId>com.xiaohongshu</groupId>
27
27
  <artifactId>infra-framework-context</artifactId>
28
28
  </dependency>
29
+ <dependency>
30
+ <groupId>org.springframework.boot</groupId>
31
+ <artifactId>spring-boot-starter-test</artifactId>
32
+ <scope>test</scope>
33
+ </dependency>
29
34
  </dependencies>
30
35
 
31
36
  </project>
@@ -47,6 +47,11 @@
47
47
  <groupId>com.xiaohongshu</groupId>
48
48
  <artifactId>infra-framework-rpc-core</artifactId>
49
49
  </dependency>
50
+ <dependency>
51
+ <groupId>org.springframework.boot</groupId>
52
+ <artifactId>spring-boot-starter-test</artifactId>
53
+ <scope>test</scope>
54
+ </dependency>
50
55
  </dependencies>
51
56
 
52
57
  </project>
@@ -0,0 +1,24 @@
1
+ package com.xiaohongshu.sns.demo.infrastructure.config.threadpool;
2
+
3
+ import java.util.concurrent.ExecutorService;
4
+ import java.util.concurrent.ThreadPoolExecutor;
5
+
6
+ import org.springframework.context.annotation.Bean;
7
+ import org.springframework.context.annotation.Configuration;
8
+
9
+ import com.xiaohongshu.infra.concurrent.PlatformExecutors;
10
+
11
+ @Configuration
12
+ public class ExecutorConfig {
13
+ @Bean(name = "demoExecutor")
14
+ public ExecutorService demoExecutor() {
15
+ /**
16
+ * 创建一个能够通过治理平台下发配置的线程池。
17
+ * 该线程池和 MoreExecutors2.dynamicExecutorService 一样,能够确保上下文传递的过程中不会丢失。
18
+ * 线程池名规范: 只包含小写字母和数字,否则无法做动态配置
19
+ */
20
+ return PlatformExecutors.dynamicExecutor("executor00", 32, 32, 4000, false,
21
+ new ThreadPoolExecutor.CallerRunsPolicy());
22
+ }
23
+
24
+ }
@@ -24,6 +24,11 @@
24
24
  <groupId>com.xiaohongshu.xray</groupId>
25
25
  <artifactId>xray-logging</artifactId>
26
26
  </dependency>
27
+ <dependency>
28
+ <groupId>org.springframework.boot</groupId>
29
+ <artifactId>spring-boot-starter-test</artifactId>
30
+ <scope>test</scope>
31
+ </dependency>
27
32
  </dependencies>
28
33
 
29
34
  <build>
@@ -0,0 +1,3 @@
1
+ {
2
+ "phabricator.uri": "http://phab.devops.xiaohongshu.com/"
3
+ }
@@ -0,0 +1,173 @@
1
+ # Thrift IDL 开发规范
2
+
3
+ ## 基础规约
4
+
5
+ 1. 命名中严禁使用拼音、拼音与英文混合的方式。
6
+ 2. `struct`和`service`命名使用UpperCamelCase风格,`struct`字段、`service`方法及参数命名统一使用lowerCamelCase风格,特殊名词除外,如`DTO`/`VIP`/`UID`等,禁止使用不规范的缩写。
7
+
8
+ ## Include
9
+
10
+ - 合理的分割Thrift定义在不同的文件中,可以提高模块性和组织性,便于管理和重用。
11
+ - 可行的方法有:
12
+ 1. 按代码类型分割,如`struct.thrift`和`service.thrift`
13
+ 2. 按业务模块分割,如`book.thrift`和`order.thrift`
14
+
15
+ ## Namespace
16
+
17
+ - Namespace用于定义各种语言的namespaces/package/module等。
18
+
19
+ ## Comment
20
+
21
+ - 使用C-style多行风格(/\*\* \*/)注释。
22
+
23
+ ## Const
24
+
25
+ - `Const`命名全部大写,单词间用下划线隔开,力求语义表达完整,不要嫌名字长。
26
+
27
+ ## Enum
28
+
29
+ - 如果变量值仅在一个固定范围内变化,用`Enum`类型定义,如status、level、type等。
30
+ - `Enum`命名统一使用UpperCamelCase风格,如`HelloWorld`。
31
+ - value命名全部大写,单词间用下划线隔开,如`HELLO_WORLD`。
32
+ - `Enum`类型的参数不要使用`required`,否则没有更新的使用方接收到新的枚举值时会解析为null进而报错。
33
+
34
+ ## Struct
35
+
36
+ - struct命名使用UpperCamelCase风格,如`HelloWorld`。
37
+ - struct中的字段统一使用lowerCamelCase风格,如`helloWorld`。
38
+ - `bool`类型的字段不要加`is`前缀,否则Thrift会生成不合语义的方法,如字段`isSuccess`会生成方法`isIsSuccess()`。
39
+ - 分割符可以是逗号(,)或是分号(;),为了清晰起见,建议在定义中只使用一种。
40
+
41
+ ## Exception
42
+
43
+ - `service`接口方法中禁止使用任何形式的`exception`(如`ClientError`,`ServerError`等),应该统一使用Response中的`base.Result`来传递信息。
44
+
45
+ ## Service
46
+
47
+ - `service`命名使用UpperCamelCase风格,如`HelloWorld`。
48
+ - `service`下定义的方法名、参数名使用lowerCamelCase风格,如`helloWorld`。
49
+ - 方法使用/\*\* \*/进行注释,内容使用[Javadoc语法](https://www.oracle.com/java/technologies/javadoc-tool.html),每个参数也用同样的方式进行注释。
50
+ - 对于调用方不需要关注调用结果的方法,可以使用`void`返回,同时声明`oneway`(数据序列化完成后client端立即返回)。
51
+ - 尽量保证同类型方法定义位置相邻,便于查找。
52
+
53
+ 推荐例子如下:
54
+
55
+ - service方法入参为两个:
56
+ - 第一个参数必须为`base.Context`,用于传递请求上下文;
57
+ - 第二个参数为业务请求参数,必须使用`struct`包装,以便后续在不修改方法签名的前提下增减请求参数,提高接口的兼容性。
58
+ - 返回值使用`struct`包装,第一个参数为`base.Result`,用于表示调用结果、错误码和异常信息等,禁止使用`service throws exception`的方式。
59
+
60
+ ## Field
61
+
62
+ ### Field Id
63
+
64
+ - 一旦有调用方开始使用,不允许调整已有字段的Field Id。
65
+ - 可以(建议)对Field Id进行一定的分段以容纳业务上的新字段,维持参数列表一定的逻辑顺序。
66
+
67
+ ### Field Requiredness
68
+
69
+ 有三种:不指定(默认)、`required`、`optional`
70
+
71
+ - 一般情况下,默认不指定即可,这也是Thrift推荐的做法。
72
+ - `optional`字段不赋值则不序列化,可以减少不必要的数据传输。
73
+ - 不要使用`required`,因为`required`字段一旦使用就难以变更,严重的限制软版本控制选项。
74
+
75
+ ---
76
+
77
+ ## 标准方法
78
+
79
+ 标准方法存在的意义是有许多方法具有非常相似的语义,通过将这些类似的方法融合到标准方法中,可以显著降低复杂性并提高一致性,这使得它们更易于学习和使用。
80
+
81
+ `Request`
82
+
83
+ - 请求参数使用`struct`包装,名字后缀为Request,如`GetBookRequest`。
84
+
85
+ `Response`
86
+
87
+ - 返回参数使用`struct`包装,名字后缀为Response,如`GetBookResponse`。
88
+ - Response struct中第一个字段为`base.Result`。
89
+
90
+ `Create`
91
+
92
+ - 新增的方法用`create`/`add`做前缀。
93
+
94
+ `Read`
95
+
96
+ - 获取单个对象的方法用`get`做前缀。
97
+ - 批量获取对象的方法使用 `multiGet` / `batchGet`做前缀。根据id查询,返回的结果应该包含一个map(key为id,value为id查询的结果)。
98
+ - 获取多个对象的方法用`list`做前缀,复数形式结尾。如`listBooks`。
99
+ - 对于更广泛的查询,应该使用自定义方法,如`searchBooks`。
100
+
101
+ `Update`
102
+
103
+ - 修改的方法用`update`做前缀。
104
+
105
+ `Delete`
106
+
107
+ - 删除的方法用`remove`/`delete`做前缀。
108
+
109
+ 常用标准方法示例:
110
+
111
+ | 动词 | 名词 | 方法名 | 请求信息 | 响应信息 |
112
+ | ------ | ---- | ---------- | ----------------- | ------------------ |
113
+ | List | Book | listBooks | ListBooksRequest | ListBooksResponse |
114
+ | Get | Book | getBook | GetBookRequest | GetBookResponse |
115
+ | Create | Book | createBook | CreateBookRequest | CreateBookResponse |
116
+ | Update | Book | updateBook | UpdateBookRequest | UpdateBookResponse |
117
+ | Rename | Book | renameBook | RenameBookRequest | RenameBookResponse |
118
+ | Delete | Book | deleteBook | DeleteBookRequest | void |
119
+
120
+ ## 标准字段
121
+
122
+ - 名称:name。
123
+ - 时间字段:应该以Time/Date/Duration做后缀,如createTime,openingDate,必须在注释中写明时间单位。
124
+ - 数量字段:应该以Count做后缀,如`fansCount`。
125
+
126
+ ## 演示例子
127
+
128
+ ```thrift
129
+ // 省略注释
130
+ struct GetBookRequest { // struct命名:遵循首字母大写的驼峰命名法
131
+ 1: i64 bookId // field命名:遵循首字母小写的驼峰命名法
132
+ // request struct:无论请求参数有多少个,request都必须用struct包装
133
+ }
134
+
135
+ struct GetBookResponse { // response struct:无论返回参数有多少个,response都必须用struct包装
136
+ 1: base.Result result // response 第一个字段必须是base.Result,包含响应结果的基础字段,如success,code,message等
137
+ 2: Book book
138
+ }
139
+
140
+ struct UpdateBookRequest {
141
+ 1: Book book
142
+ ...
143
+ }
144
+
145
+ struct UpdateBookResponse {
146
+ 1: base.Result result
147
+ }
148
+
149
+ service BookService { // service命名:遵循首字母大写的驼峰命名法
150
+
151
+ GetBookResponse getBook( // 方法命名:首字母小写的驼峰命名法
152
+ 1: base.Context context // Context参数:第一个参数必须是base.Context,
153
+ 2: GetBookRequest request // 业务请求参数:业务请求参数必须使用struct包装,严禁直接使用基本类型参数
154
+ )
155
+
156
+ UpdateBookResponse updateBook(
157
+ 1: base.Context context
158
+ 2: UpdateBookRequest request
159
+ )
160
+ }
161
+ ```
162
+
163
+ ## TODO
164
+
165
+ - 具体目录和描述
166
+ - 注释内容
167
+ - 定义组织结构 struct service const 位置
168
+ - dto
169
+ XXXCreateDTO
170
+ XXXUpdateDTO
171
+ XXXQueryDTO
172
+ XXXListItemDTO
173
+ XXXPaginationDTO
@@ -0,0 +1,61 @@
1
+ # SDK开发指南
2
+
3
+ ## 工程结构
4
+
5
+ 关键文件目录如下(以[example](example)为例):
6
+
7
+ ```
8
+ ├── .gitlab-ci.yml // 必须,Gitlab CI配置文件
9
+ ├── maven_project // Java项目必须,实际打包的基础目录,结构遵循maven约定
10
+ │ ├── pom.xml // 必须指定sdk的maven坐标和依赖等
11
+ │ ├── src // java源文件的存放目录
12
+ ├── hello.thrift // 必须,thrift idl文件
13
+ └── sdk-spec.yml // 必须,sdk配置文件,包括依赖版本和编译选项等
14
+
15
+ ```
16
+
17
+ sdk-spec.yml:
18
+
19
+ ```
20
+ dependencies:
21
+ sns-idls/base: 1.1.7 # 依赖sns-idls/base项目,tag为1.1.7
22
+ build:
23
+ go:
24
+ enabled: true # 是否开启go编译 [gosdk](https://wiki.xiaohongshu.com/pages/viewpage.action?pageId=43487207)
25
+ recurse: true or false # 是否递归编译引用的thrift文件(默认会将com.xiaohongshu.infra.rpc.base包删除)
26
+ # 使用recurse参数,需要将build:go的image升级为docker-reg.devops.xiaohongshu.com/shequ/sns-gosdk-ci:feature-onlyGo-20211222-345b8798
27
+
28
+ ```
29
+
30
+ thrift idl开发参考[Thrift IDL开发规范](./README.md)
31
+
32
+ ## 发布
33
+
34
+ 1. `commit push`和`tag`都会触发gitlab ci自动编译、打包、发布,过程可在Pipelines->Jobs中查看。
35
+ 2. `commit push`会发布SNAPSHOT版本,artifact version为:`分支名-SNAPSHOT`(**分支名中的`'/'`会替换为`'-'`**)。
36
+ 3. `tag`会发布RELEASE版本,artifact version为:`${tag_name}`(**${tag_name}必须符合正则表达式:`/^\d+\.\d+\.\d+$/`,如`1.2.3`**)。
37
+
38
+ 如:
39
+
40
+ - 分支`feature/add-field` ,对应version为`feature-add-field-SNAPSHOT`。
41
+ - tag`1.2.3`,对应version为`1.2.3`。
42
+
43
+ ## 工作流
44
+
45
+ 1. 开发阶段,sdk项目检出开发分支,项目中使用SNAPSHOT版本的sdk依赖。
46
+ 2. 开发完毕,将开发分支合入master,打tag(如`$ git tag -a 1.2.3 -m 'my version 1.2.3'`),项目中改为使用RELEASE版本的sdk依赖。
47
+
48
+ ## 定制化
49
+
50
+ Java sdk会以`maven_project`目录作为打包的基础目录,因此可以在目录中添加代码来定制sdk的功能。
51
+
52
+ 例如,使用[SpringBoot AutoConfiguration](https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-auto-configuration.html)为sdk开发自动配置功能,参考[例子](example)。
53
+
54
+ ## 常见问题
55
+
56
+ 1. Invalid remote: origin
57
+
58
+ The project you were looking for could not be found.
59
+
60
+ 原因是CI任务没有该项目的权限,需要开启 CI Deploy Key:
61
+ 项目首页 -> Settings -> Repository -> Deploy Keys -> enable deploy key: sns-sdk-ci-base & sns-sdk-ci
@@ -0,0 +1,3 @@
1
+ {
2
+ "phabricator.uri": "http://phab.devops.xiaohongshu.com/"
3
+ }
@@ -0,0 +1,26 @@
1
+ stages:
2
+ - build
3
+ # 根据项目类型保留需要build的stage 并删掉其他stage
4
+ build:java:
5
+ stage: build
6
+ image: docker-reg.devops.xiaohongshu.com/shequ/sns-sdk-ci:latest
7
+ script:
8
+ - skr -p ${CI_PROJECT_NAME} -c ${CI_COMMIT_REF_NAME}
9
+ only:
10
+ - branches
11
+ - /^\d+\.\d+\.\d+$/
12
+
13
+ build:go:
14
+ stage: build
15
+ image: docker-reg.devops.xiaohongshu.com/shequ/sns-gosdk-ci:latest
16
+ script:
17
+ - skr -p ${CI_PROJECT_NAME} -c ${CI_COMMIT_REF_NAME}
18
+ only:
19
+ - branches
20
+ - /^\d+\.\d+\.\d+$/
21
+
22
+ build:node:
23
+ stage: build
24
+ image: docker-reg.devops.xiaohongshu.com/fe/ts-generator:latest
25
+ script:
26
+ - DEBUG=common-bin tsGen build --branch ${CI_COMMIT_REF_NAME} --userEmail ${GITLAB_USER_EMAIL} --ciId ${CI_COMMIT_SHA:0:8} --pId ${CI_PROJECT_ID}
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ filename="./hello.thrift"
4
+ thrift --gen java:generated_annotations=undated -out maven_project/src/main/java/ $filename
@@ -0,0 +1,29 @@
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
+ }
@@ -0,0 +1,95 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://maven.apache.org/POM/4.0.0"
3
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+ <modelVersion>4.0.0</modelVersion>
6
+
7
+ <groupId>com.xiaohongshu.sns.thrift</groupId>
8
+ <artifactId>hello-sdk</artifactId>
9
+ <version>${sdk.version}</version>
10
+
11
+ <properties>
12
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
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>
17
+
18
+ <build>
19
+ <plugins>
20
+ <plugin>
21
+ <groupId>org.apache.maven.plugins</groupId>
22
+ <artifactId>maven-compiler-plugin</artifactId>
23
+ <configuration>
24
+ <source>1.8</source>
25
+ <target>1.8</target>
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>
56
+
57
+ <dependencies>
58
+
59
+ <dependency>
60
+ <groupId>com.xiaohongshu</groupId>
61
+ <artifactId>thrift-springboot</artifactId>
62
+ </dependency>
63
+
64
+ <dependency>
65
+ <groupId>org.springframework.boot</groupId>
66
+ <artifactId>spring-boot-autoconfigure</artifactId>
67
+ </dependency>
68
+
69
+ <dependency>
70
+ <groupId>org.springframework.boot</groupId>
71
+ <artifactId>spring-boot-starter-test</artifactId>
72
+ <scope>test</scope>
73
+ </dependency>
74
+
75
+ <dependency>
76
+ <groupId>org.springframework.boot</groupId>
77
+ <artifactId>spring-boot-configuration-processor</artifactId>
78
+ <optional>true</optional>
79
+ </dependency>
80
+ </dependencies>
81
+
82
+ <distributionManagement>
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>
94
+
95
+ </project>