Skip to content

Commit 88c073c

Browse files
committed
refactor: adjust to capa v1.0.8 configuration setting
1 parent 8399d6c commit 88c073c

File tree

7 files changed

+48
-62
lines changed

7 files changed

+48
-62
lines changed

capa-spi-aws-config/src/main/java/group/rxcloud/capa/spi/aws/config/AwsCapaConfigStore.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package group.rxcloud.capa.spi.aws.config;
1818

1919
import com.google.common.collect.Lists;
20+
import group.rxcloud.capa.component.CapaConfigurationProperties;
2021
import group.rxcloud.capa.component.configstore.ConfigurationItem;
2122
import group.rxcloud.capa.component.configstore.StoreConfig;
2223
import group.rxcloud.capa.component.configstore.SubscribeResp;
@@ -282,7 +283,7 @@ private <T> SubscribeResp<T> convert(ConfigurationItem<T> conf, String appId) {
282283
SubscribeResp<T> subscribeResp = new SubscribeResp<>();
283284
subscribeResp.setItems(Lists.newArrayList(conf));
284285
subscribeResp.setAppId(appId);
285-
subscribeResp.setStoreName(AwsCapaConfigurationProperties.AppConfigProperties.Settings.getAwsAppConfigName());
286+
subscribeResp.setStoreName(CapaConfigurationProperties.Settings.getStoreNames().get(0));
286287
return subscribeResp;
287288
}
288289

capa-spi-aws-config/src/main/java/group/rxcloud/capa/spi/aws/config/AwsCapaConfigurationProperties.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,16 @@ interface AppConfigProperties {
3030

3131
abstract class Settings {
3232

33-
private static String awsAppConfigName = "AWS AppConfig";
3433
private static String awsAppConfigEnv = "ENV";
3534

36-
private static final String CONFIGURATION_COMPONENT_STORE_NAME = "CONFIGURATION_COMPONENT_STORE_NAME";
3735
private static final String CONFIG_AWS_APP_CONFIG_ENV = "CONFIG_AWS_APP_CONFIG_ENV";
3836

3937
static {
40-
Properties properties = CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.apply("configuration");
41-
42-
awsAppConfigName = properties.getProperty(CONFIGURATION_COMPONENT_STORE_NAME, awsAppConfigName);
43-
4438
Properties awsProperties = CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.apply("configuration-aws");
4539

4640
awsAppConfigEnv = awsProperties.getProperty(CONFIG_AWS_APP_CONFIG_ENV, awsAppConfigEnv);
4741
}
4842

49-
public static String getAwsAppConfigName() {
50-
return awsAppConfigName;
51-
}
52-
5343
public static String getConfigAwsAppConfigEnv() {
5444
return awsAppConfigEnv;
5545
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# configuration component store names
2+
CONFIGURATION_COMPONENT_STORE_NAMES=aws.appconfig
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
# configuration component
2-
group.rxcloud.capa.component.configstore.CapaConfigStore=group.rxcloud.capa.spi.aws.config.AwsCapaConfigStore
3-
#
4-
# configuration component store name
5-
CONFIGURATION_COMPONENT_STORE_NAME=AWS AppConfig
2+
group.rxcloud.capa.component.configstore.CapaConfigStore=group.rxcloud.capa.spi.aws.config.AwsCapaConfigStore

capa-spi-aws-config/src/test/java/group/rxcloud/capa/spi/aws/config/AwsCapaConfigStoreTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package group.rxcloud.capa.spi.aws.config;
1818

1919
import com.google.common.collect.Lists;
20+
import group.rxcloud.capa.component.CapaConfigurationProperties;
2021
import group.rxcloud.capa.component.configstore.ConfigurationItem;
2122
import group.rxcloud.capa.component.configstore.StoreConfig;
2223
import group.rxcloud.capa.component.configstore.SubscribeResp;
@@ -62,7 +63,7 @@ class AwsCapaConfigStoreTest {
6263
public void setUp() {
6364
ins = new AwsCapaConfigStore(new DefaultObjectSerializer());
6465
StoreConfig storeConfig = new StoreConfig();
65-
storeConfig.setStoreName(AwsCapaConfigurationProperties.AppConfigProperties.Settings.getAwsAppConfigName());
66+
storeConfig.setStoreName(CapaConfigurationProperties.Settings.getStoreNames().get(0));
6667

6768
AppConfigAsyncClient client = PowerMockito.mock(AppConfigAsyncClient.class);
6869
Whitebox.setInternalState(ins, "appConfigAsyncClient", client);
@@ -124,7 +125,7 @@ void testDoSubscribe_SuccessInitialization() {
124125
SubscribeResp<User> userSubscribeResp = subscribeRespFlux.blockFirst();
125126
Assertions.assertNotNull(userSubscribeResp);
126127
Assertions.assertEquals("100012345", userSubscribeResp.getAppId());
127-
Assertions.assertEquals("AWS AppConfig", userSubscribeResp.getStoreName());
128+
Assertions.assertEquals("aws.appconfig", userSubscribeResp.getStoreName());
128129
Assertions.assertEquals("test.json", userSubscribeResp.getItems().get(0).getKey());
129130
Assertions.assertEquals("reckless", userSubscribeResp.getItems().get(0).getContent().getName());
130131
Assertions.assertEquals(new Integer(28), userSubscribeResp.getItems().get(0).getContent().getAge());
@@ -196,7 +197,7 @@ void testDoSubscribe_SuccessSubscribeChanges() throws NoSuchFieldException, Ille
196197
SubscribeResp<User> userSubscribeResp = subscribeRespFlux.skip(1L).blockFirst();
197198
Assertions.assertNotNull(userSubscribeResp);
198199
Assertions.assertEquals("100012345", userSubscribeResp.getAppId());
199-
Assertions.assertEquals("AWS AppConfig", userSubscribeResp.getStoreName());
200+
Assertions.assertEquals("aws.appconfig", userSubscribeResp.getStoreName());
200201
Assertions.assertEquals("test.json", userSubscribeResp.getItems().get(0).getKey());
201202
Assertions.assertEquals("reckless", userSubscribeResp.getItems().get(0).getContent().getName());
202203
Assertions.assertEquals(new Integer(28), userSubscribeResp.getItems().get(0).getContent().getAge());

capa-spi-aws-mesh/src/main/java/group/rxcloud/capa/spi/aws/mesh/http/AwsCapaHttp.java

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ public AwsCapaHttp(OkHttpClient httpClient, CapaObjectSerializer objectSerialize
5656
}
5757

5858
@Override
59-
protected <T> CompletableFuture<HttpResponse<T>> invokeSpiApi(
60-
String appId,
61-
String method,
62-
Object requestData,
63-
String httpMethod,
64-
Map<String, String> headers,
65-
Map<String, List<String>> urlParameters,
66-
TypeRef<T> type,
67-
RpcServiceOptions rpcServiceOptions) {
59+
protected <T> CompletableFuture<HttpResponse<T>> invokeSpiApi(String appId,
60+
String method,
61+
Object requestData,
62+
String httpMethod,
63+
Map<String, String> headers,
64+
Map<String, List<String>> urlParameters,
65+
TypeRef<T> type,
66+
RpcServiceOptions rpcServiceOptions) {
6867
Objects.requireNonNull(rpcServiceOptions, "rpcServiceOptions");
6968
AwsToAwsHttpServiceMeshInvoker awsToAwsHttpServiceMeshInvoker = new AwsToAwsHttpServiceMeshInvoker();
7069
return awsToAwsHttpServiceMeshInvoker.doInvokeSpiApi(
@@ -91,15 +90,14 @@ private interface AwsHttpInvoker {
9190
* @param rpcServiceOptions the rpc service options
9291
* @return the async completable future
9392
*/
94-
<T> CompletableFuture<HttpResponse<T>> doInvokeSpiApi(
95-
String appId,
96-
String method,
97-
Object requestData,
98-
String httpMethod,
99-
Map<String, String> headers,
100-
Map<String, List<String>> urlParameters,
101-
TypeRef<T> type,
102-
AwsRpcServiceOptions rpcServiceOptions);
93+
<T> CompletableFuture<HttpResponse<T>> doInvokeSpiApi(String appId,
94+
String method,
95+
Object requestData,
96+
String httpMethod,
97+
Map<String, String> headers,
98+
Map<String, List<String>> urlParameters,
99+
TypeRef<T> type,
100+
AwsRpcServiceOptions rpcServiceOptions);
103101
}
104102

105103
/**
@@ -113,15 +111,14 @@ private class AwsToAwsHttpServiceMeshInvoker implements AwsHttpInvoker {
113111
private static final String POST = "POST";
114112

115113
@Override
116-
public <T> CompletableFuture<HttpResponse<T>> doInvokeSpiApi(
117-
String appId,
118-
String method,
119-
Object requestData,
120-
String httpMethod,
121-
Map<String, String> headers,
122-
Map<String, List<String>> urlParameters,
123-
TypeRef<T> type,
124-
AwsRpcServiceOptions rpcServiceOptions) {
114+
public <T> CompletableFuture<HttpResponse<T>> doInvokeSpiApi(String appId,
115+
String method,
116+
Object requestData,
117+
String httpMethod,
118+
Map<String, String> headers,
119+
Map<String, List<String>> urlParameters,
120+
TypeRef<T> type,
121+
AwsRpcServiceOptions rpcServiceOptions) {
125122
AwsRpcServiceOptions.AwsToAwsServiceOptions awsToAwsServiceOptions = rpcServiceOptions.getAwsToAwsServiceOptions();
126123
final String serviceId = awsToAwsServiceOptions.getServiceId();
127124
if (StringUtils.isBlank(serviceId)) {
@@ -148,16 +145,15 @@ public <T> CompletableFuture<HttpResponse<T>> doInvokeSpiApi(
148145
servicePort);
149146
}
150147

151-
private <T> CompletableFuture<HttpResponse<T>> doAsyncInvoke(
152-
String method,
153-
Object requestData,
154-
String httpMethod,
155-
Map<String, String> headers,
156-
Map<String, List<String>> urlParameters,
157-
TypeRef<T> type,
158-
String serviceId,
159-
String namespace,
160-
int servicePort) {
148+
private <T> CompletableFuture<HttpResponse<T>> doAsyncInvoke(String method,
149+
Object requestData,
150+
String httpMethod,
151+
Map<String, String> headers,
152+
Map<String, List<String>> urlParameters,
153+
TypeRef<T> type,
154+
String serviceId,
155+
String namespace,
156+
int servicePort) {
161157
// generate app mesh http url
162158
final String appMeshHttpUrl = AwsCapaRpcProperties.AppMeshProperties.Settings.getRpcAwsAppMeshTemplate()
163159
.replace("{serviceId}", serviceId)
@@ -185,12 +181,11 @@ private <T> CompletableFuture<HttpResponse<T>> doAsyncInvoke(
185181
return asyncInvoke0;
186182
}
187183

188-
private <T> CompletableFuture<HttpResponse<T>> invokeHttp(
189-
String url,
190-
Object requestData,
191-
String httpMethod,
192-
Map<String, String> headers,
193-
TypeRef<T> type) {
184+
private <T> CompletableFuture<HttpResponse<T>> invokeHttp(String url,
185+
Object requestData,
186+
String httpMethod,
187+
Map<String, String> headers,
188+
TypeRef<T> type) {
194189
// generate http request body
195190
RequestBody body = getRequestBodyWithSerialize(requestData, headers);
196191
Headers header = getRequestHeaderWithParams(headers);

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<java.version>8</java.version>
7474
<file.encoding>UTF-8</file.encoding>
7575
<maven.version>3.8.1</maven.version>
76-
<capa.version>1.0.7.RELEASE</capa.version>
76+
<capa.version>1.0.8-alpha-1</capa.version>
7777
<aws-sdk.version>2.17.40</aws-sdk.version>
7878
<junit.version>5.3.1</junit.version>
7979
<mockito-core.version>3.6.0</mockito-core.version>

0 commit comments

Comments
 (0)