baldimir commented on code in PR #4178:
URL:
https://github.com/apache/incubator-kie-kogito-runtimes/pull/4178#discussion_r2799513645
##########
quarkus/addons/asyncapi/deployment/src/main/java/org/kie/kogito/quarkus/serverless/workflow/asyncapi/AsyncAPIInfoConverter.java:
##########
@@ -47,20 +49,47 @@ public Optional<AsyncInfo> apply(String id) {
}
private static AsyncInfo from(AsyncAPI asyncApi) {
- Map<String, AsyncChannelInfo> map = new HashMap<>();
- for (Entry<String, ChannelItem> entry :
asyncApi.getChannels().entrySet()) {
- addChannel(map, entry.getValue().getPublish(), entry.getKey() +
"_out", true);
- addChannel(map, entry.getValue().getSubscribe(), entry.getKey(),
false);
+ Map<String, String> channelIdToAddress =
buildChannelAddressMap(asyncApi);
+ Map<String, AsyncChannelInfo> channelInfoByOperationId =
buildOperationChannelInfoMap(asyncApi, channelIdToAddress);
+ return new AsyncInfo(channelInfoByOperationId);
+ }
+
+ // AsyncAPI v3.0.0: channels are separate top-level objects with addresses
+ private static Map<String, String> buildChannelAddressMap(AsyncAPI
asyncApi) {
+ Map<String, String> channelIdToAddress = new HashMap<>();
+ if (asyncApi.getChannels() != null) {
+ for (Entry<String, Object> ch : asyncApi.getChannels().entrySet())
{
+ if (ch.getValue() instanceof Channel channel) {
+ String channelId = ch.getKey();
+ String address =
Optional.ofNullable(channel.getAddress()).orElse(channelId);
+ channelIdToAddress.put(channelId, address);
+ }
+ }
}
- return new AsyncInfo(map);
+ return channelIdToAddress;
}
- private static void addChannel(Map<String, AsyncChannelInfo> map,
Operation operation, String channelName, boolean publish) {
- if (operation != null) {
- String operationId = operation.getOperationId();
- if (operationId != null) {
- map.putIfAbsent(operationId, new AsyncChannelInfo(channelName,
publish));
+ // AsyncAPI v3.0.0: operations reference channels via $ref, action is
SEND/RECEIVE
Review Comment:
If you want to document what a method does, please use standard JavaDoc
comments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]