pandaapo commented on code in PR #4569:
URL: https://github.com/apache/eventmesh/pull/4569#discussion_r1398560467


##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -233,16 +233,32 @@ private void startConnector() throws Exception {
     }
 
     private CloudEvent convertRecordToEvent(ConnectRecord connectRecord) {
+        CloudEventBuilder cloudEventBuilder = CloudEventBuilder.v1();
+
+        cloudEventBuilder.withId(UUID.randomUUID().toString())
+                .withSubject(config.getPubSubConfig().getSubject())
+                .withSource(URI.create("/"))
+                .withDataContentType("application/cloudevents+json")
+                .withType(CLOUD_EVENTS_PROTOCOL_NAME)
+                
.withData(Objects.requireNonNull(JsonUtils.toJSONString(connectRecord.getData())).getBytes(StandardCharsets.UTF_8))
+                .withExtension("ttl", 10000);
+
+        for (String key : connectRecord.getExtensions().keySet()) {
+            Object extension = connectRecord.getExtensionObj(key);
+            if (extension instanceof Integer ||
+                    extension instanceof Long ||
+                    extension instanceof Short ||
+                    extension instanceof Byte ||
+                    extension instanceof Boolean ||
+                    extension instanceof Float ||
+                    extension instanceof Double ||
+                    extension instanceof Character ||
+                    extension instanceof String) {
+                cloudEventBuilder.withExtension(key, 
String.valueOf(extension));

Review Comment:
   1\. Since `DefaultKeyValue` supports storing Object directly, is it 
necessary to convert them all to String? Otherwise, the meaning of 
`DefaultKeyValue`'s `put(String key, Object value)` method, `getObject()` 
method, and `Map<String, Object> properties property` is not great.
   
   2\. `CloudEventBuilder.withExtension(String, )` also supports URI, 
OffsetDateTime, and byte[] types. Is it possible to add them in?
   
   3\. Can Integer, Long, Short, Float, and Double be unified as Number?
   
   1\. 
既然`DefaultKeyValue`支持直接保存Object,是不是不用再全都转化成String类型了?要不然`DefaultKeyValue`的`put(String
 key, Object value)`方法、`getObject()`方法和`Map<String, Object> 
properties`属性的意义就不大了。
   2\. `CloudEventBuilder.withExtension(String, 
)`还支持URI、OffsetDateTime、byte[]这些类型,是不是可以加入进来?
   3\.Integer、Long、Short、Float、Double是不是可以简化成Number?



##########
eventmesh-openconnect/eventmesh-openconnect-java/src/main/java/org/apache/eventmesh/openconnect/SourceWorker.java:
##########
@@ -233,16 +233,32 @@ private void startConnector() throws Exception {
     }
 
     private CloudEvent convertRecordToEvent(ConnectRecord connectRecord) {
+        CloudEventBuilder cloudEventBuilder = CloudEventBuilder.v1();
+
+        cloudEventBuilder.withId(UUID.randomUUID().toString())
+                .withSubject(config.getPubSubConfig().getSubject())
+                .withSource(URI.create("/"))
+                .withDataContentType("application/cloudevents+json")
+                .withType(CLOUD_EVENTS_PROTOCOL_NAME)
+                
.withData(Objects.requireNonNull(JsonUtils.toJSONString(connectRecord.getData())).getBytes(StandardCharsets.UTF_8))
+                .withExtension("ttl", 10000);
+
+        for (String key : connectRecord.getExtensions().keySet()) {
+            Object extension = connectRecord.getExtensionObj(key);
+            if (extension instanceof Integer ||
+                    extension instanceof Long ||
+                    extension instanceof Short ||
+                    extension instanceof Byte ||
+                    extension instanceof Boolean ||
+                    extension instanceof Float ||
+                    extension instanceof Double ||
+                    extension instanceof Character ||
+                    extension instanceof String) {
+                cloudEventBuilder.withExtension(key, 
String.valueOf(extension));

Review Comment:
   1\. Since `DefaultKeyValue` supports storing Object directly, is it 
necessary to convert them all to String? Otherwise, the meaning of 
`DefaultKeyValue`'s `put(String key, Object value)` method, `getObject()` 
method, and `Map<String, Object> properties property` is not great.
   
   2\. `CloudEventBuilder.withExtension(String, )` also supports URI, 
OffsetDateTime, and byte[] types. Is it possible to add them in?
   
   3\. Can Integer, Long, Short, Float, and Double be unified as Number?
   
   1\. 
既然`DefaultKeyValue`支持直接保存Object,是不是不用再全都转化成String类型了?要不然`DefaultKeyValue`的`put(String
 key, Object value)`方法、`getObject()`方法和`Map<String, Object> 
properties`属性的意义就不大了。
   2\. `CloudEventBuilder.withExtension(String, 
)`还支持URI、OffsetDateTime、byte[]这些类型,是不是可以加入进来?
   3\.Integer、Long、Short、Float、Double是不是可以简化成Number?



-- 
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]

Reply via email to