Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates in gRPC and JDBC client #33

Merged
merged 2 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ include::../modules/con_mg_changes-in-vertx-mongodb-client.adoc[leveloffset=+1]

include::../chapters/assembly_mg_changes-in-vertx-redis-client.adoc[leveloffset=+1]

include::../community_features/rabbitmq-client.adoc[leveloffset=+1]

ifdef::parent-context-of-changes-in-client-components[:context: {parent-context-of-changes-in-client-components}]
ifndef::parent-context-of-changes-in-client-components[:!context:]
14 changes: 14 additions & 0 deletions asciidoc/chapters/assembly_mg_changes-in-clustering.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ifdef::context[:parent-context-of-changes-in-clustering: {context}]

[id="changes-in-clustering_{context}"]
= Changes in clustering
:context: changes-in-clustering

This section explains the changes in clustering.

include::../modules/con_mg_changes-in-infinispan-cluster-manager.adoc[leveloffset=+1]

include::../community_features/ignite.adoc[leveloffset=+1]

ifdef::parent-context-of-changes-in-clustering[:context: {parent-context-of-changes-in-clustering}]
ifndef::parent-context-of-changes-in-clustering[:!context:]
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ include::../modules/con_mg_changes-in-json.adoc[leveloffset=+1]

include::../modules/con_mg_changes-in-vertx-web.adoc[leveloffset=+1]

include::con_mg_changes-in-vertx-web-graphql.adoc[leveloffset=+1]

include::../modules/con_mg_changes-in-micrometer-metrics.adoc[leveloffset=+1]

include::../modules/con_mg_changes-in-vertx-openapi.adoc[leveloffset=+1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ include::../modules/con_mg_use-future-methods-for-asynchronous-operations.adoc[l

include::../modules/con_mg_no_dependency_on_the_jackson_databind_library.adoc[leveloffset=+1]

include::../modules/con_mg_support_for_opentracing.adoc[leveloffset=+1]

include::../modules/con_mg_handling_deprecations_and_removals.adoc[leveloffset=+1]

ifdef::parent-context-of-what-is-new-and-different-in-vertx-4[:context: {parent-context-of-what-is-new-and-different-in-vertx-4}]
Expand Down
2 changes: 0 additions & 2 deletions asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ This guide describes the updates in {VertX} {v4} release. Use the information to

include::modules/con_mg-about-vertx.adoc[leveloffset=+1]

include::../modules/proc_configuring-your-application-to-use-vertx.adoc[leveloffset=+1]

include::chapters/assembly_mg_what-is-new-and-different-in-vertx-4.adoc[leveloffset=+1]

include::chapters/assembly_mg_changes-in-common-components.adoc[leveloffset=+1]
Expand Down
139 changes: 110 additions & 29 deletions asciidoc/modules/con_mg_changes-in-vertx-grpc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,123 @@ The following section describes the changes in {VertX} gRPC.

== New gRPC compiler plugin

In earlier releases of {VertX}, to compile a gRPC `.proto` descriptor, you had to work with fork of the official gRPC compiler. This fork is maintained by the Eclipse project. Working with the fork was complex.
In {VertX} {v4}, the module `protoc-gen-grpc-java` is longer available. This module was a fork of the official gRPC compiler. In earlier releases of {VertX}, you had to work with this fork. This fork is maintained by the Eclipse project. Working with the fork was complex.

In previous releases, to work with gRPC, the following details were added to `pom.xml` file.

[source,xml]
----
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.vertx:protoc-gen-grpc-java:1.25.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
</plugin>
<!-- Vert.x 3.x -->
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.2.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<!-- NOTE: the gav coordinates point to the 3.x only compiler fork -->
<pluginArtifact>io.vertx:protoc-gen-grpc-java:${vertx.grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
...
</plugin>
----

In {VertX} {v4}, a new gRPC compiler plugin is available. This plugin uses the official gRPC compiler instead of the fork. To work with the new gRPC plugin, add the following details to `pom.xml` file.

[source,xml]
----
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
<protocPlugins>
<protocPlugin>
<id>vertx-grpc-protoc-plugin</id>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc-protoc-plugin</artifactId>
<version>${vertx.version}</version>
<mainClass>io.vertx.grpc.protoc.plugin.VertxGrpcGenerator</mainClass>
</protocPlugin>
</protocPlugins>
</configuration>
</plugin>
<!-- Vert.x 4.0 -->
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.2.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<!-- NOTE: the gav coordinates point to the official compiler -->
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${vertx.grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
<protocPlugins>
<!-- NEW: a plugin is added to generate the Vert.x specific code -->
<protocPlugin>
<id>vertx-grpc-protoc-plugin</id>
<groupId>io.vertx</groupId>
<artifactId>vertx-grpc-protoc-plugin</artifactId>
<version>${vertx.version}</version>
<mainClass>io.vertx.grpc.protoc.plugin.VertxGrpcGenerator</mainClass>
</protocPlugin>
</protocPlugins>
</configuration>
...
</plugin>
----

== Migrating the generated code

In {VertX} {v4}, the new compiler is used. When the new gRPC plugin is used, the generated code is not written in the same source file. This is because the compiler does not allow custom code generation on its base class. The plugins must generate a new class with a different name to save the code.

In earlier releases of {VertX}, the older gRPC plugin would write the generated code in the same source file.

For example, if you have the following descriptor:

[source,proto]
----
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
----

In {VertX} {v3x}, the code would be generated in the `GreeterGrpc` class.

[source,java]
----
// 3.x
GreeterGrpc.GreeterVertxImplBase service =
new GreeterGrpc.GreeterVertxImplBase() {
...
}
----

In {VertX} {v4}, the code is generated in the `VertxGreeterGrpc` class.

[source,java]
----
// 4.x
VertxGreeterGrpc.GreeterVertxImplBase service =
new VertxGreeterGrpc.GreeterVertxImplBase() {
...
}
----

== gRPC APIs support futures

In {VertX} {v4}, the gRPC APIs support futures. The gRPC plugin generates promisified APIs. These APIs use the standard {VertX} input and output arguments, which makes it easier to create standard {VertX} applications.

The following example shows you use of promises in {VertX} {v3x}.

sangeetaraghu marked this conversation as resolved.
Show resolved Hide resolved
[source,java]
----
// 3.x
GreeterGrpc.GreeterVertxImplBase service =
new GreeterGrpc.GreeterVertxImplBase() {
@Override
public void sayHello(HelloRequest request, Promise<HelloReply> future) {
future.complete(
HelloReply.newBuilder().setMessage(request.getName()).build());
}
}
----

The following example shows use of futures in {VertX} {v4}.

sangeetaraghu marked this conversation as resolved.
Show resolved Hide resolved
[source,java]
----
// 4.x
VertxGreeterGrpc.GreeterVertxImplBase service =
new VertxGreeterGrpc.GreeterVertxImplBase() {
@Override
public Future<HelloReply> sayHello(HelloRequest request) {
return Future.succeededFuture(
HelloReply.newBuilder()
.setMessage(request.getName())
.build());
}
}
----
Loading