Skip to content

Use stream json api in protobuf v31+#3342

Open
chenBright wants to merge 1 commit into
apache:masterfrom
chenBright:stream_json
Open

Use stream json api in protobuf v31+#3342
chenBright wants to merge 1 commit into
apache:masterfrom
chenBright:stream_json

Conversation

@chenBright

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: resolve

Problem Summary:

protocolbuffers/protobuf@cff2bb5#diff-a7f751e303f1778830da9721fb6dc4f02aa9208a88c7374aa1556682d92d8c63
Protobuf v31+ supports streaming APIs for converting between JSON and messages.

Streaming API wrappers using bRPC are no longer needed.

What is changed and the side effects?

Changed:

Side effects:

  • Performance effects:

  • Breaking backward compatibility:


Check List:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates bRPC’s protobuf↔ProtoJSON conversion path to use protobuf’s native streaming JSON APIs when building against protobuf v31+ (per GOOGLE_PROTOBUF_VERSION gating), reducing reliance on bRPC’s legacy wrapper approach while retaining the existing fallback for older protobuf versions.

Changes:

  • Switch ProtoMessageToProtoJson(...) to google::protobuf::json::MessageToJsonStream(...) for GOOGLE_PROTOBUF_VERSION >= 6031000.
  • Switch ProtoJsonToProtoMessage(...) to google::protobuf::json::JsonStreamToMessage(...) for GOOGLE_PROTOBUF_VERSION >= 6031000.
  • Mark brpc_load_balancer_unittest.cpp as size=large in Bazel to mitigate CI timeouts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
test/BUILD.bazel Increases Bazel timeout class for brpc_load_balancer_unittest.cpp by setting it to large.
src/json2pb/pb_to_json.cpp Uses protobuf’s streaming Message→JSON API when available; keeps the existing BinaryToJsonStream fallback otherwise.
src/json2pb/json_to_pb.cpp Uses protobuf’s streaming JSON→Message API when available; keeps the existing JsonToBinaryStream+Parse fallback otherwise.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants