You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "azexcy (via GitHub)" <gi...@apache.org> on 2023/04/01 06:12:26 UTC

[GitHub] [shardingsphere] azexcy commented on a diff in pull request #24924: Use JsonFormat print records of CDC response

azexcy commented on code in PR #24924:
URL: https://github.com/apache/shardingsphere/pull/24924#discussion_r1155064207


##########
kernel/data-pipeline/cdc/client/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/client/example/Bootstrap.java:
##########
@@ -36,7 +44,18 @@ public static void main(final String[] args) {
         // Pay attention to the time zone, to avoid the problem of incorrect time zone, it is best to ensure that the time zone of the program is consistent with the time zone of the database server
         // and mysql-connector-java 5.x version will ignore serverTimezone jdbc parameter and use the default time zone in the program
         // TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
-        StartCDCClientParameter parameter = new StartCDCClientParameter(records -> log.info("records: {}", records));
+        TypeRegistry registry = TypeRegistry.newBuilder().add(EmptyProto.getDescriptor().getMessageTypes()).add(TimestampProto.getDescriptor().getMessageTypes())
+                .add(WrappersProto.getDescriptor().getMessageTypes()).build();
+        Printer printer = JsonFormat.printer().usingTypeRegistry(registry);
+        StartCDCClientParameter parameter = new StartCDCClientParameter(records -> {
+            for (Record each : records) {
+                try {
+                    log.info("record: {}", printer.print(each));

Review Comment:
   <img width="793" alt="image" src="https://user-images.githubusercontent.com/101622833/229268923-ed646f28-2ea8-4e5c-ae2c-03a71a685794.png">
   seem it's necessary for JSON representation of an Any value
   
   https://protobuf.dev/reference/protobuf/google.protobuf/



-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org