Use stream json api in protobuf v31+#3342
Open
chenBright wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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(...)togoogle::protobuf::json::MessageToJsonStream(...)forGOOGLE_PROTOBUF_VERSION >= 6031000. - Switch
ProtoJsonToProtoMessage(...)togoogle::protobuf::json::JsonStreamToMessage(...)forGOOGLE_PROTOBUF_VERSION >= 6031000. - Mark
brpc_load_balancer_unittest.cppassize=largein 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: