feat(compiler): support C++ gRPC code generation - #3877
Draft
BaldDemian wants to merge 1 commit into
Draft
Conversation
BaldDemian
force-pushed
the
cpp-grpc
branch
3 times, most recently
from
July 22, 2026 10:05
d93b1e2 to
cce1a87
Compare
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.
Why?
Support C++ gRPC code generation.
What does this PR do?
Overview
This PR adds C++ gRPC code generation support.
All unary, server-streaming, client-streaming, and bidirectional RPC types are supported.
They integrate with gRPC C++ synchronous APIs.
Fory-backed codec
Generated gRPC code uses Fory as codec. Given that the codec is relatively small, it is generated directed within each
*_service_grpc.h.On writes, codec moves serialized bytes into a gRPC
Slice, avoiding an additional outbound payload copy. On reads, it uses a singleByteBufferslice when possible and merges fragmented buffers only when necessary.Error-handling
To make the logic more robust, this PR also adds gRPC-related naming collision detection and escaping.
This PR also considers special characters of C++ such as compilation guards.
Generated model and service headers use sanitized include guards;
the shared Fory codec is protected by
FORY_GENERATED_GRPC_SERIALIZATION_TRAITS_;each
grpc::SerializationTraits<T>specialization has a stable, type-specific guard derived from a sanitized fully qualified type name and a SHA-256 prefix. This prevents duplicate specializations when several generated service headers use the same message type.Testing
This PR adds compiler-side pytests and C++-Java gRPC interop tests. It also adds a dedicated job in the CI.
Documentation
This PR adds documentation for the usage and example of the C++ gRPC code generation feature.
Related issues
Close #3276.
AI Contribution Checklist
yes/noyes, I included a completed AI Contribution Checklist in this PR description and the requiredAI Usage Disclosure.yes, my PR description includes the requiredai_reviewsummary and screenshot evidence or equivalent persisted links of the final clean AI review results from both fresh reviewers described inAI_POLICY.md, the Fory-guided reviewer and the independent general reviewer, on the current PR diff or current HEAD after the latest code changes.Does this PR introduce any user-facing change?
N/A.
Benchmark
N/A.