2121import group .rxcloud .capa .infrastructure .exceptions .CapaException ;
2222import group .rxcloud .capa .infrastructure .serializer .CapaObjectSerializer ;
2323import group .rxcloud .capa .spi .aws .mesh .config .AwsRpcServiceOptions ;
24- import group .rxcloud .capa .spi .aws .mesh .constants .AwsRpcConstants ;
25- import group .rxcloud .capa .spi .aws .mesh .http .serialzer .AwsCapaSerialzerProvider ;
24+ import group .rxcloud .capa .spi .aws .mesh .http .serializer .AwsCapaSerializerProvider ;
2625import group .rxcloud .capa .spi .config .RpcServiceOptions ;
2726import group .rxcloud .capa .spi .http .CapaSerializeHttpSpi ;
2827import group .rxcloud .cloudruntimes .utils .TypeRef ;
3837import java .util .Objects ;
3938import java .util .concurrent .CompletableFuture ;
4039
40+ import static group .rxcloud .capa .spi .aws .mesh .constants .AwsRpcConstants .AppMeshProperties .AWS_APP_MESH_TEMPLATE ;
41+
4142public class AwsCapaHttp extends CapaSerializeHttpSpi {
4243
4344 private static final Logger logger = LoggerFactory .getLogger (AwsCapaHttp .class );
@@ -49,7 +50,7 @@ public class AwsCapaHttp extends CapaSerializeHttpSpi {
4950 * @param objectSerializer the object serializer
5051 */
5152 public AwsCapaHttp (OkHttpClient httpClient , CapaObjectSerializer objectSerializer ) {
52- super (httpClient , AwsCapaSerialzerProvider .getSerializerOrDefault (objectSerializer ));
53+ super (httpClient , AwsCapaSerializerProvider .getSerializerOrDefault (objectSerializer ));
5354 }
5455
5556 @ Override
@@ -59,22 +60,19 @@ protected <T> CompletableFuture<HttpResponse<T>> invokeSpiApi(String appId,
5960 Map <String , String > headers ,
6061 TypeRef <T > type ,
6162 RpcServiceOptions rpcServiceOptions ) {
62-
6363 Objects .requireNonNull (rpcServiceOptions , "rpcServiceOptions" );
6464 AwsToAwsHttpServiceMeshInvoker awsToAwsHttpServiceMeshInvoker = new AwsToAwsHttpServiceMeshInvoker ();
65- CompletableFuture <HttpResponse <T >> httpResponseCompletableFuture
66- = awsToAwsHttpServiceMeshInvoker .doInvokeSpiApi (
67- appId ,
68- method ,
69- requestData ,
70- headers ,
71- type ,
72- (AwsRpcServiceOptions ) rpcServiceOptions );
73-
65+ CompletableFuture <HttpResponse <T >> httpResponseCompletableFuture =
66+ awsToAwsHttpServiceMeshInvoker .doInvokeSpiApi (
67+ appId ,
68+ method ,
69+ requestData ,
70+ headers ,
71+ type ,
72+ (AwsRpcServiceOptions ) rpcServiceOptions );
7473 return httpResponseCompletableFuture ;
7574 }
7675
77-
7876 private interface AwsHttpInvoker {
7977
8078 /**
@@ -95,7 +93,6 @@ <T> CompletableFuture<HttpResponse<T>> doInvokeSpiApi(String appId,
9593 Map <String , String > headers ,
9694 TypeRef <T > type ,
9795 AwsRpcServiceOptions rpcServiceOptions );
98-
9996 }
10097
10198 /**
@@ -115,8 +112,8 @@ public <T> CompletableFuture<HttpResponse<T>> doInvokeSpiApi(String appId,
115112 Map <String , String > headers ,
116113 TypeRef <T > type ,
117114 AwsRpcServiceOptions rpcServiceOptions ) {
118- AwsRpcServiceOptions .AwsToAwsServiceOptions awsToAwsServiceOptions
119- = rpcServiceOptions .getAwsToAwsServiceOptions ();
115+ AwsRpcServiceOptions .AwsToAwsServiceOptions awsToAwsServiceOptions =
116+ rpcServiceOptions .getAwsToAwsServiceOptions ();
120117
121118 final String serviceId = awsToAwsServiceOptions .getServiceId ();
122119 final int servicePort = awsToAwsServiceOptions .getServicePort ();
@@ -129,15 +126,14 @@ public <T> CompletableFuture<HttpResponse<T>> doInvokeSpiApi(String appId,
129126 return doAsyncInvoke (method , requestData , headers , type , serviceId , servicePort );
130127 }
131128
132-
133129 private <T > CompletableFuture <HttpResponse <T >> doAsyncInvoke (String method ,
134130 Object requestData ,
135131 Map <String , String > headers ,
136132 TypeRef <T > type ,
137133 String serviceId ,
138134 int servicePort ) {
139135 // generate app mesh http url
140- final String appMeshHttpUrl = AwsRpcConstants . RpcProperties . AWS_APP_MESH_TEMPLATE
136+ final String appMeshHttpUrl = AWS_APP_MESH_TEMPLATE
141137 .replace ("{serviceId}" , serviceId )
142138 .replace ("{servicePort}" , String .valueOf (servicePort ))
143139 .replace ("{operation}" , method );
@@ -146,7 +142,7 @@ private <T> CompletableFuture<HttpResponse<T>> doAsyncInvoke(String method,
146142 CompletableFuture <HttpResponse <T >> asyncInvoke0 = post (appMeshHttpUrl , requestData , headers , type );
147143 asyncInvoke0 .exceptionally (throwable -> {
148144 if (logger .isWarnEnabled ()) {
149- logger .warn ("[CtripCapaHttp ] async invoke error" , throwable );
145+ logger .warn ("[AwsCapaHttp ] async invoke error" , throwable );
150146 }
151147 throw new CapaException (CapaErrorContext .DEPENDENT_SERVICE_ERROR , throwable );
152148 });
@@ -170,6 +166,5 @@ private <T> CompletableFuture<HttpResponse<T>> post(String url,
170166
171167 return doAsyncInvoke0 (request , type );
172168 }
173-
174169 }
175170}
0 commit comments