Skip to content

Conversation

Jozott00
Copy link
Collaborator

Subsystem
gRPC/Native

Problem Description
One part of the gRPC implementation is the Protobuf wire format encoding and decoding.
This PR adds support for all values (except for sub-messages) to encode them into a kotlinx.io.Buffer and decode a buffer back to Kotlin values.

Solution
This PR adds two new main interfaces to the commonMain: WireEncoder and WireDecode.
Both interfaces must be implemented platform specifically. This PR provides implementations for the Kotlin Native platform.

Most of the encoding and decoding is done by the Protobuf C++ library, which is called using C-Interop. To avoid unnecessary data copying during decoding, the C++ decoder is directly bridged to the ZeroCopyInputSource that provides low-level access to the kotlinx.io.Buffer. The implementation of the ZeroCopyInputSource highly relies on the implementation of kotlinx.io.Buffer.

@Jozott00 Jozott00 self-assigned this Jul 25, 2025
@Jozott00 Jozott00 added the feature New feature or request label Jul 25, 2025
@Jozott00 Jozott00 changed the title Grpc pb native gRPC/Native: Add Wire Format encoder and decoder Jul 28, 2025
@Mr3zee Mr3zee self-requested a review July 28, 2025 11:21
Copy link
Member

@Mr3zee Mr3zee left a comment

Choose a reason for hiding this comment

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

Great work! It was quite pleasant to read.
I have some questions, and some minor comments, please address them.

@Jozott00 Jozott00 requested a review from Mr3zee July 28, 2025 15:52
Jozott00 added 14 commits July 28, 2025 19:23
…er and decoder with buffers

Signed-off-by: Johannes Zottele <[email protected]>
@Mr3zee Mr3zee merged commit ebb2761 into grpc-native Jul 29, 2025
2 of 3 checks passed
@Mr3zee Mr3zee deleted the grpc-pb-native branch July 29, 2025 10:03
Mr3zee added a commit that referenced this pull request Jul 30, 2025
Mr3zee added a commit that referenced this pull request Aug 1, 2025
Mr3zee added a commit that referenced this pull request Aug 4, 2025
Mr3zee added a commit that referenced this pull request Aug 8, 2025
Mr3zee added a commit that referenced this pull request Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants