You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "sandynz (via GitHub)" <gi...@apache.org> on 2023/03/31 10:54:50 UTC

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

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


##########
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:
   Could we remove `@type`? (e.g. `"@type": "type.googleapis.com/google.protobuf.Empty"`)



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