Skip to content

Add support for WireFormat configuration#266

Merged
zZHorizonZz merged 6 commits into
eclipse-vertx:mainfrom
zZHorizonZz:wire-format-class
Jun 30, 2026
Merged

Add support for WireFormat configuration#266
zZHorizonZz merged 6 commits into
eclipse-vertx:mainfrom
zZHorizonZz:wire-format-class

Conversation

@zZHorizonZz

@zZHorizonZz zZHorizonZz commented May 4, 2026

Copy link
Copy Markdown
Member

Motivation:

  • Allow customization of JSON printer and parser configurations for gRPC transcoding trough WireFormat configuration.

Changes:

  • Added ability to configure supported wireformats on server.
  • Added JsonWireFormat and ProtobufWireFormat as concrete implementations of WireFormat.
  • Updated GrpcMessageEncoder and GrpcMessageDecoder to respect custom wire formats.
  • Added ProtobufJsonReader and ProtobufJsonWriter.
  • Updated transcoding logic to use specific wire formats.

Closes: #261
Supersedes: #252

@zZHorizonZz
zZHorizonZz requested a review from vietj May 4, 2026 06:11
@zZHorizonZz
zZHorizonZz force-pushed the wire-format-class branch from a42d0e6 to c1f0e5f Compare May 4, 2026 06:11
@zZHorizonZz

Copy link
Copy Markdown
Member Author

@mutexd If you want you can also review, I think this should allow more configuration in the future

@zZHorizonZz
zZHorizonZz force-pushed the wire-format-class branch from c1f0e5f to efc804b Compare May 4, 2026 06:38
@mutexd

mutexd commented May 11, 2026

Copy link
Copy Markdown
Contributor

@mutexd If you want you can also review, I think this should allow more configuration in the future

It looks good to me. I also tried it out and it works just as expected. Thanks.

@zZHorizonZz
zZHorizonZz force-pushed the wire-format-class branch 6 times, most recently from 6e15eab to 76d5171 Compare May 18, 2026 13:34
Comment thread vertx-grpc-common/src/main/java/io/vertx/grpc/common/JsonWireFormat.java Outdated
@vietj

vietj commented Jun 4, 2026

Copy link
Copy Markdown
Member

we should move ProtobufJsonReader and ProtobufJsonWriter to impl package and not expose this for the moment, and we open it to module that actually use it, I want to keep the surface API small

Comment thread vertx-grpc-common/src/main/java/io/vertx/grpc/common/impl/ProtobufJsonReader.java Outdated
Comment thread vertx-grpc-common/src/main/java/io/vertx/grpc/common/impl/ProtobufJsonWriter.java Outdated
return 415;
}

if (!options.isFormatEnabled(details.format)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is that case tested ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is vertx-grpc-server/src/test/java/io/vertx/tests/server/FormatSupportTest.java

- Allow customization of JSON printer and parser configurations for gRPC transcoding trough WireFormat configuration.

Changes:

- Added ability to configure supported wireformats on server.
- Added `JsonWireFormat` and `ProtobufWireFormat` as concrete implementations of `WireFormat`.
- Updated `GrpcMessageEncoder` and `GrpcMessageDecoder` to respect custom wire formats.
- Added `ProtobufJsonReader` and `ProtobufJsonWriter`.
- Updated transcoding logic to use specific wire formats.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
Motivation:

- Simplify API for configuring JSON reader and writer flags in `JsonWireFormat`.

Changes:

- Replaced `WriterConfig` and `ReaderConfig` with direct boolean flags in `JsonWireFormat`.
- Updated `GrpcMessageEncoder` and `GrpcMessageDecoder` to use the simplified `JsonWireFormat`.
- Refactored `ProtobufJsonWriter` and `ProtobufJsonReader` to accept simplified `JsonWireFormat`.
- Updated tests to use the new `JsonWireFormat` flag-based API.
- Removed unused configuration classes and redundant imports.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
…and extensibility.

Motivation:

- Improve readability and ensure robust handling of `WireFormat` values in EventBus gRPC server implementation.

Changes:

- Refactored validation and parsing of the `grpc-wire-format` header in `EventBusGrpcServerImpl` to handle unknown formats gracefully.
- Replaced hardcoded string comparisons with `WireFormat` enumeration values in tests and implementation.
- Updated `dispatch` method to accept `WireFormat` directly, simplifying usage.
- Adjusted related JavaDocs for better description of `grpc-wire-format`.
Motivation:

- Align method names with standard practices by removing the `get` prefix for boolean accessors to enhance readability and maintain consistency across the codebase.

Changes:

- Renamed all `get*` methods to remove the `get` prefix in `JsonWireFormat`.
- Updated `ProtobufJsonWriterImpl` and `ProtobufJsonReaderImpl` to use the renamed methods.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
Motivation:

- Reduce unnecessary complexity by introducing a flag-based implementation for `JsonWireFormat`.

Changes:

- Simplified `JsonWireFormat` by replacing boolean fields with a compact flag-based system.
- Added caching for `JsonWireFormat` to improve memory efficiency.
- Introduced a `mediaType` method to both `JsonWireFormat` and `ProtobufWireFormat` for determining content type dynamically.
- Updated all components to use the new media type method for content type handling.
- Replaced hardcoded wire format comparisons with reusable `mediaType`.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
…nto single classes.

Motivation:

- Simplify the codebase by eliminating separate `Impl` classes that provide no additional value.
- Improve clarity by making `ProtobufJsonReader` and `ProtobufJsonWriter` self-contained.

Changes:

- Merged `ProtobufJsonReaderImpl` into `ProtobufJsonReader`.
- Merged `ProtobufJsonWriterImpl` into `ProtobufJsonWriter`.
- Updated constructors to handle `JsonWireFormat` directly within unified classes.
- Removed redundant `Impl` classes and adjusted usage across the codebase.
@zZHorizonZz
zZHorizonZz merged commit 69c8384 into eclipse-vertx:main Jun 30, 2026
6 checks passed
@zZHorizonZz
zZHorizonZz deleted the wire-format-class branch July 1, 2026 03:54
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.

Add option including JSON default value for transcoding

3 participants