Skip to content

Commit fc6a2a1

Browse files
committed
feat: add multi component support
1 parent 30406b6 commit fc6a2a1

File tree

18 files changed

+83
-52
lines changed

18 files changed

+83
-52
lines changed

sdk-component/src/main/java/group/rxcloud/capa/component/configstore/CapaConfigStoreBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public CapaConfigStore build() {
8181
* @return Instance of {@link CapaConfigStore} implementor
8282
*/
8383
private CapaConfigStore buildCapaConfigStore() {
84+
// TODO: 2021/11/30 build multi component
8485
// load spi capa config store impl
8586
return CapaClassLoader.loadComponentClassObj(
8687
"configuration",

sdk-component/src/main/java/group/rxcloud/capa/component/pubsub/CapaPubSubBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public CapaPubSub build() {
5252
* @return Instance of {@link CapaPubSub} implementor
5353
*/
5454
private CapaPubSub buildCapaPubSub() {
55+
// TODO: 2021/11/30 build multi component
5556
return CapaClassLoader.loadComponentClassObj("pubsub", CapaPubSub.class);
5657
}
5758
}

sdk-infrastructure/src/main/java/group/rxcloud/capa/infrastructure/hook/ConfigurationHooks.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@
2828
import java.util.List;
2929
import java.util.Map;
3030

31+
/**
32+
* The Mixer configuration hooks.
33+
*/
3134
public interface ConfigurationHooks extends ConfigurationRuntimes {
3235

33-
String currentStoreName();
34-
35-
String currentAppId();
36+
/**
37+
* Registry Store Names.
38+
*/
39+
List<String> registryStoreNames();
3640

3741
@Override
3842
default <T> Mono<List<ConfigurationItem<T>>> getConfiguration(String storeName, String appId, List<String> keys, Map<String, String> metadata, TypeRef<T> type) {

sdk-infrastructure/src/main/java/group/rxcloud/capa/infrastructure/hook/TelemetryHooks.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
import io.opentelemetry.context.propagation.ContextPropagators;
2323
import reactor.core.publisher.Mono;
2424

25+
/**
26+
* The Mixer telemetry hooks.
27+
*/
2528
public interface TelemetryHooks extends TelemetryRuntimes {
2629

2730
@Override

sdk-spi-demo/src/main/java/group/rxcloud/capa/spi/demo/http/DemoCapaHttp.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.slf4j.Logger;
2727
import org.slf4j.LoggerFactory;
2828

29+
import java.util.List;
2930
import java.util.Map;
3031
import java.util.concurrent.CompletableFuture;
3132

@@ -47,12 +48,15 @@ public DemoCapaHttp(OkHttpClient httpClient, CapaObjectSerializer objectSerializ
4748
}
4849

4950
@Override
50-
protected <T> CompletableFuture<HttpResponse<T>> invokeSpiApi(String appId,
51-
String method,
52-
Object requestData,
53-
Map<String, String> headers,
54-
TypeRef<T> type,
55-
RpcServiceOptions rpcServiceOptions) {
51+
protected <T> CompletableFuture<HttpResponse<T>> invokeSpiApi(
52+
String appId,
53+
String method,
54+
Object requestData,
55+
String httpMethod,
56+
Map<String, String> headers,
57+
Map<String, List<String>> urlParameters,
58+
TypeRef<T> type,
59+
RpcServiceOptions rpcServiceOptions) {
5660
DemoRpcServiceOptions demoRpcServiceOptions = (DemoRpcServiceOptions) rpcServiceOptions;
5761
logger.info("[DemoCapaHttp.invokeSpiApi] rpcServiceOptions[{}]", demoRpcServiceOptions);
5862

sdk-spi/src/main/java/group/rxcloud/capa/spi/http/CapaHttpSpi.java

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import group.rxcloud.capa.spi.http.config.CapaSpiOptionsLoader;
2323
import group.rxcloud.capa.spi.http.config.CapaSpiProperties;
2424
import group.rxcloud.capa.spi.http.config.RpcServiceOptions;
25-
import group.rxcloud.cloudruntimes.domain.core.invocation.HttpExtension;
2625
import group.rxcloud.cloudruntimes.utils.TypeRef;
2726
import okhttp3.OkHttpClient;
2827
import org.slf4j.Logger;
@@ -41,15 +40,18 @@ public abstract class CapaHttpSpi extends CapaHttp {
4140

4241
private static final Logger logger = LoggerFactory.getLogger(CapaHttpSpi.class);
4342

43+
/**
44+
* Instantiates a new Capa http spi.
45+
*
46+
* @param httpClient the http client
47+
* @param objectSerializer the object serializer
48+
*/
4449
public CapaHttpSpi(OkHttpClient httpClient, CapaObjectSerializer objectSerializer) {
4550
super(httpClient, objectSerializer);
4651
}
4752

4853
/**
4954
* Templates, delegate to specific http invoker.
50-
*
51-
* @param httpMethod Ignore, fix to POST. FIXME
52-
* @param urlParameters Ignore, fix to EMPTY. FIXME
5355
*/
5456
@Override
5557
protected <T> CompletableFuture<HttpResponse<T>> doInvokeApi(String httpMethod,
@@ -73,22 +75,6 @@ protected <T> CompletableFuture<HttpResponse<T>> doInvokeApi(String httpMethod,
7375
logger.debug("[CapaHttpSpi] invoke rpc context[{}]", context);
7476
}
7577
}
76-
// FIXME Ignore, fix to POST.
77-
if (!HttpExtension.POST.getMethod().toString().equalsIgnoreCase(httpMethod)) {
78-
if (logger.isWarnEnabled()) {
79-
logger.warn("[CapaHttpSpi] invoke rpc httpMethod[{}] only support POST now.",
80-
httpMethod);
81-
}
82-
httpMethod = HttpExtension.POST.getMethod().toString();
83-
}
84-
// FIXME Ignore, fix to EMPTY.
85-
if (urlParameters != null && !urlParameters.isEmpty()) {
86-
if (logger.isWarnEnabled()) {
87-
logger.warn("[CapaHttpSpi] invoke rpc urlParameters[{}] not supported now.",
88-
urlParameters);
89-
}
90-
urlParameters = null;
91-
}
9278

9379
// parse url path segments
9480
Objects.requireNonNull(pathSegments, "pathSegments");
@@ -112,7 +98,7 @@ protected <T> CompletableFuture<HttpResponse<T>> doInvokeApi(String httpMethod,
11298

11399
// spi invoke
114100
CompletableFuture<HttpResponse<T>> invokeSpiApi =
115-
invokeSpiApi(appId, method, requestData, headers, type, rpcServiceOptions);
101+
invokeSpiApi(appId, method, requestData, httpMethod, headers, urlParameters, type, rpcServiceOptions);
116102
invokeSpiApi.whenComplete((tHttpResponse, throwable) -> {
117103
if (throwable != null) {
118104
if (logger.isWarnEnabled()) {
@@ -141,6 +127,9 @@ protected <T> CompletableFuture<HttpResponse<T>> doInvokeApi(String httpMethod,
141127

142128
/**
143129
* Override to get the configuration of the corresponding appId.
130+
*
131+
* @param appId the app id
132+
* @return the rpc service options
144133
*/
145134
protected RpcServiceOptions getRpcServiceOptions(String appId) {
146135
CapaSpiOptionsLoader capaSpiOptionsLoader = CapaSpiProperties.getSpiOptionsLoader();
@@ -154,15 +143,20 @@ protected RpcServiceOptions getRpcServiceOptions(String appId) {
154143
* @param appId the app id
155144
* @param method the invoke method
156145
* @param requestData the request data
146+
* @param httpMethod the http method
157147
* @param headers the headers
148+
* @param urlParameters the url parameters
158149
* @param type the response type
159150
* @param rpcServiceOptions the rpc service options
160151
* @return the async completable future
161152
*/
162-
protected abstract <T> CompletableFuture<HttpResponse<T>> invokeSpiApi(String appId,
163-
String method,
164-
Object requestData,
165-
Map<String, String> headers,
166-
TypeRef<T> type,
167-
RpcServiceOptions rpcServiceOptions);
153+
protected abstract <T> CompletableFuture<HttpResponse<T>> invokeSpiApi(
154+
String appId,
155+
String method,
156+
Object requestData,
157+
String httpMethod,
158+
Map<String, String> headers,
159+
Map<String, List<String>> urlParameters,
160+
TypeRef<T> type,
161+
RpcServiceOptions rpcServiceOptions);
168162
}

sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaReadWriteSpanSpi.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@
2424
*/
2525
public abstract class CapaReadWriteSpanSpi extends CapaReadWriteSpan {
2626

27-
2827
public CapaReadWriteSpanSpi(String tracerName, String version, String schemaUrl,
2928
ReadWriteSpan span) {
3029
super(tracerName, version, schemaUrl, span);
3130
}
32-
3331
}

sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaSpanBuilderSpi.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ public CapaSpanBuilderSpi(String tracerName, String version, String schemaUrl, S
2828
SpanBuilder spanBuilder) {
2929
super(tracerName, version, schemaUrl, spanName, spanBuilder);
3030
}
31-
3231
}

sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaTracerBuilderSpi.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ public abstract class CapaTracerBuilderSpi extends CapaTracerBuilder {
2727
public CapaTracerBuilderSpi(String tracerName, TracerBuilder builder) {
2828
super(tracerName, builder);
2929
}
30-
3130
}

sdk-spi/src/main/java/group/rxcloud/capa/spi/telemetry/CapaTracerSpi.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ public abstract class CapaTracerSpi extends CapaTracer {
2727
public CapaTracerSpi(String tracerName, String version, String schemaUrl, Tracer tracer) {
2828
super(tracerName, version, schemaUrl, tracer);
2929
}
30-
3130
}

0 commit comments

Comments
 (0)