Skip to content

Conversation

Jozott00
Copy link
Collaborator

@Jozott00 Jozott00 commented Aug 1, 2025

Subsystem
gRPC/Common - Protobuf

Description
This PR adds presence tracking for fields with explicit presence on the wire.
It does this by adding a presenceMask to each message, implemented as BitSet. The presence of each field that has explicit presence is represented by a bit in the mask.

If a required field (required field in proto2 or a field annotated with [ LEGACY_REQUIRED ] in editions) is not present after construction, an error is thrown.
This is done for both, user constructed messages (e.i. by the generated invoke function) and messages that were decoded from the wire using the message's decode function.

Additionally, the PR adds generation of an implementation of the MessageCodec interface, used by the gRPC implementation to encode and decode messages. It is made available as object in the companion object of the generated internal message. E.g. MyMessageInternal.CODEC

@Jozott00 Jozott00 self-assigned this Aug 1, 2025
@Jozott00 Jozott00 added the feature New feature or request label Aug 1, 2025
@Jozott00 Jozott00 requested a review from Mr3zee August 1, 2025 17:46
Signed-off-by: Johannes Zottele <[email protected]>
Signed-off-by: Johannes Zottele <[email protected]>
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! Please fix some minor issues before merging

Signed-off-by: Johannes Zottele <[email protected]>
@Jozott00 Jozott00 merged commit 6b60ba6 into grpc-common Aug 4, 2025
2 of 3 checks passed
Mr3zee pushed a commit that referenced this pull request Aug 4, 2025
…d generation of the MessageCodec implementation (#421)

* grpc-pb: Refactor subtyping hierarchy

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Add presence tracking and required field check

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Add PresenceIndices object that holds the presence indices of all fields.

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Move BitSet to utils

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Add MessageCodec object for each message

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Use only fully qualified names for kotlinx.rpc.grpc.pb.* classes

Signed-off-by: Johannes Zottele <[email protected]>

* Revert kotlin version increase

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Remove demo test

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Address PR comments

Signed-off-by: Johannes Zottele <[email protected]>

---------

Signed-off-by: Johannes Zottele <[email protected]>
@Jozott00 Jozott00 deleted the grpc/pb-gen branch August 7, 2025 14:13
Mr3zee pushed a commit that referenced this pull request Aug 8, 2025
…d generation of the MessageCodec implementation (#421)

* grpc-pb: Refactor subtyping hierarchy

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Add presence tracking and required field check

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Add PresenceIndices object that holds the presence indices of all fields.

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Move BitSet to utils

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Add MessageCodec object for each message

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Use only fully qualified names for kotlinx.rpc.grpc.pb.* classes

Signed-off-by: Johannes Zottele <[email protected]>

* Revert kotlin version increase

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Remove demo test

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Address PR comments

Signed-off-by: Johannes Zottele <[email protected]>

---------

Signed-off-by: Johannes Zottele <[email protected]>
Mr3zee pushed a commit that referenced this pull request Aug 21, 2025
…d generation of the MessageCodec implementation (#421)

* grpc-pb: Refactor subtyping hierarchy

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Add presence tracking and required field check

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Add PresenceIndices object that holds the presence indices of all fields.

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Move BitSet to utils

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Add MessageCodec object for each message

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Use only fully qualified names for kotlinx.rpc.grpc.pb.* classes

Signed-off-by: Johannes Zottele <[email protected]>

* Revert kotlin version increase

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Remove demo test

Signed-off-by: Johannes Zottele <[email protected]>

* grpc-pb: Address PR comments

Signed-off-by: Johannes Zottele <[email protected]>

---------

Signed-off-by: Johannes Zottele <[email protected]>
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