@rdmind/rdmind 0.1.8 → 0.1.9-alpha.1
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 +287 -78
- package/locales/en.js +3 -1
- package/locales/zh.js +3 -0
- 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 +5 -8
- 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 +57 -38
- 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/template/sns-demo-start/src/main/java/com/xiaohongshu/sns/demo/start/provider/.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,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
|
package/template/sns-demo-start/src/main/java/com/xiaohongshu/sns/demo/start/provider/.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
|
-
}
|