Skip to content

Commit 384cc0f

Browse files
committed
refactor: rpc optimize
1 parent f7e1d87 commit 384cc0f

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import group.rxcloud.capa.infrastructure.CapaProperties;
2222
import group.rxcloud.capa.infrastructure.exceptions.CapaErrorContext;
2323
import group.rxcloud.capa.infrastructure.exceptions.CapaException;
24+
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
2426

2527
import java.util.Properties;
2628

@@ -29,6 +31,8 @@
2931
*/
3032
public interface AwsCapaRpcProperties {
3133

34+
Logger logger = LoggerFactory.getLogger(AwsCapaRpcProperties.class);
35+
3236
interface AppMeshProperties {
3337

3438
abstract class Settings {
@@ -59,6 +63,9 @@ abstract class Settings {
5963

6064
// FIXME: 2021/12/15 use trip logic currently
6165
rpcAwsAppMeshNamespace = CapaFoundation.getNamespace(FoundationType.TRIP);
66+
67+
logger.info("[Capa.Rpc.Client.config] [AwsCapaRpcProperties.AppMeshProperties] rpcAwsAppMeshTemplate[{}] rpcAwsAppMeshPort[{}] rpcAwsAppMeshNamespace[{}]",
68+
rpcAwsAppMeshTemplate, rpcAwsAppMeshPort, rpcAwsAppMeshNamespace);
6269
}
6370

6471
public static Integer getRpcAwsAppMeshPort() {
@@ -90,6 +97,9 @@ abstract class Settings {
9097
Properties properties = CapaProperties.COMPONENT_PROPERTIES_SUPPLIER.apply("rpc-aws");
9198

9299
rpcAwsAppMeshSerializer = properties.getProperty(RPC_AWS_APP_MESH_SERIALIZER, rpcAwsAppMeshSerializer);
100+
101+
logger.info("[Capa.Rpc.Client.config] [AwsCapaRpcProperties.SerializerProperties] rpcAwsAppMeshSerializer[{}]",
102+
rpcAwsAppMeshSerializer);
93103
}
94104

95105
public static String getRpcAwsAppMeshSerializer() {

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ private void setRequestHeaderOfAccept(Map<String, String> headers, RequestBody b
9393
accepts.add(userAcceptValue);
9494
}
9595
// 2. set accept header same with content-type
96-
final String contentType = body.contentType().toString();
97-
if (contentType != null && contentType.length() > 0) {
98-
accepts.add(contentType);
96+
if (body.contentType() != null) {
97+
final String contentType = Objects.requireNonNull(body.contentType()).toString();
98+
if (contentType.length() > 0) {
99+
accepts.add(contentType);
100+
}
99101
}
100102
// 3. add */* at last
101103
accepts.add(ACCEPT_ALL);
@@ -199,6 +201,10 @@ private <T> CompletableFuture<HttpResponse<T>> doAsyncInvoke(String method,
199201

200202
if (HttpExtension.GET.getMethod().toString().equals(httpMethod)) {
201203
// TODO: 2021/11/30 append urlParameters to url
204+
if (logger.isWarnEnabled()) {
205+
logger.warn("[Capa.Rpc.Client.http] [AwsCapaHttp.doAsyncInvoke] GET not supported now, urlParameters[{}]",
206+
urlParameters);
207+
}
202208
}
203209

204210
// async invoke
@@ -210,7 +216,7 @@ private <T> CompletableFuture<HttpResponse<T>> doAsyncInvoke(String method,
210216
type);
211217
asyncInvoke0.exceptionally(throwable -> {
212218
if (logger.isWarnEnabled()) {
213-
logger.warn("[AwsCapaHttp] async invoke error", throwable);
219+
logger.warn("[Capa.Rpc.Client.http] [AwsCapaHttp.doAsyncInvoke] async invoke error", throwable);
214220
}
215221
throw new CapaException(CapaErrorContext.DEPENDENT_SERVICE_ERROR, throwable);
216222
});
@@ -229,6 +235,11 @@ private <T> CompletableFuture<HttpResponse<T>> invokeHttp(String url,
229235

230236
Headers header = getRequestHeaderWithParams(headers);
231237

238+
if (logger.isDebugEnabled()) {
239+
logger.debug("[Capa.Rpc.Client.http] [AwsCapaHttp.invokeHttp] final request url[{}] header[{}] httpMethod[{}]",
240+
url, header, httpMethod);
241+
}
242+
232243
// make http request
233244
Request request = new Request.Builder()
234245
.url(url)

0 commit comments

Comments
 (0)