Skip to content

Refactor gRPC plugin implementation for modular architecture#206

Merged
zZHorizonZz merged 9 commits intoeclipse-vertx:mainfrom
zZHorizonZz:no-jprotoc
Oct 20, 2025
Merged

Refactor gRPC plugin implementation for modular architecture#206
zZHorizonZz merged 9 commits intoeclipse-vertx:mainfrom
zZHorizonZz:no-jprotoc

Conversation

@zZHorizonZz
Copy link
Member

Refactor the gRPC plugin by replacing VertxGrpcGeneratorImpl with a new modular architecture to improve maintainability, and allow future extendability.

This PR supersedes: #172

@zZHorizonZz zZHorizonZz requested a review from vietj September 9, 2025 10:44
@zZHorizonZz zZHorizonZz added the enhancement New feature or request label Sep 9, 2025
- Replace `VertxGrpcGeneratorImpl` with a new modular architecture for better maintainability.
- Update Protobuf plugin configuration in `pom.xml` to reflect new plugin structure with `io.github.ascopes`.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
…ss modules

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
List<ServiceDescriptor> services = new ArrayList<>();

for (DescriptorProtos.FileDescriptorProto fileProto : request.getProtoFileList()) {
if (!request.getFileToGenerateList().contains(fileProto.getName())) {
Copy link
Member

Choose a reason for hiding this comment

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

filtering should be done by the caller, that is the VertxGrpcGenerator should filter the list to be processed by the ProtocRequestConverter instead of relying on it to skip the files that should not be generated

Copy link
Member

Choose a reason for hiding this comment

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

so convertServices should actually convert a single service and iteration should be done by the generator instead

@@ -0,0 +1,21 @@
package io.vertx.grpc.plugin.template;
Copy link
Member

Choose a reason for hiding this comment

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

at the moment we have only one engine, so we just need the MustatcheTemplateEngine class and the builder does not need to care about it because it's always the same

*/
public abstract class CodeGenerator {

protected final TemplateEngine templateEngine;
Copy link
Member

Choose a reason for hiding this comment

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

the CodeGenerator does not need to keep a reference to the template engine as we only have a single engine that is the mustache engine, this will simplify a bit.

return null;
}

public static class Builder {
Copy link
Member

Choose a reason for hiding this comment

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

this is only used by VertxGrpcGenerator to build a list of generator that are then iterated to generate the code, we don't really need that at the moment. The setup then generate can be fully done in the VertxGrpcGenerator.

Copy link
Member

@vietj vietj left a comment

Choose a reason for hiding this comment

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

more simplification :-)

…gine, simplify template handling, and refactor code generation APIs for reduced complexity.

Signed-off-by: Daniel Fiala <danfiala23@gmail.com>
@zZHorizonZz zZHorizonZz requested a review from vietj October 10, 2025 10:38
- Replace `mixedLower` with `formatMethodName` for clarity and consistency.
- Leverage `LowerCamelCase` utility for improved maintainability.
- Simplify file handling logic by removing `FileWriter` and `ProtocFileWriter` classes.
- Refactor `CodeGenerationEngine` to eliminate dependency on file writing.
@zZHorizonZz zZHorizonZz merged commit 8cad839 into eclipse-vertx:main Oct 20, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants