-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the vertx protoc plugin2 instead of the legacy one
- Loading branch information
Showing
15 changed files
with
67 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,8 @@ | |
import io.vertx.core.Launcher; | ||
import io.vertx.core.net.SocketAddress; | ||
import io.vertx.example.grpc.Messages; | ||
import io.vertx.example.grpc.VertxConversationalServiceGrpc; | ||
import io.vertx.example.grpc.VertxConversationalServiceGrpcClient; | ||
import io.vertx.grpc.client.GrpcClient; | ||
import io.vertx.grpc.client.GrpcClientChannel; | ||
|
||
/* | ||
* @author <a href="mailto:[email protected]">Paulo Lopes</a> | ||
|
@@ -22,10 +21,9 @@ public void start() { | |
|
||
// Create the channel | ||
GrpcClient client = GrpcClient.client(vertx); | ||
GrpcClientChannel channel = new GrpcClientChannel(client, SocketAddress.inetSocketAddress(8080, "localhost")); | ||
|
||
// Get a stub to use for interacting with the remote service | ||
VertxConversationalServiceGrpc.ConversationalServiceVertxStub stub = VertxConversationalServiceGrpc.newVertxStub(channel); | ||
VertxConversationalServiceGrpcClient stub = new VertxConversationalServiceGrpcClient(client, SocketAddress.inetSocketAddress(8080, "localhost")); | ||
|
||
// Call the remote service | ||
stub.fullDuplexCall(writeStream -> { | ||
|
@@ -34,8 +32,10 @@ public void start() { | |
vertx.setTimer(500L, t -> { | ||
writeStream.write(Messages.StreamingOutputCallRequest.newBuilder().build()); | ||
}); | ||
}).handler(req -> { | ||
System.out.println("Client: received response"); | ||
}).onSuccess(resp -> { | ||
resp.handler(msg -> { | ||
System.out.println("Client: received response"); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,8 @@ | |
import io.vertx.core.Launcher; | ||
import io.vertx.core.net.SocketAddress; | ||
import io.vertx.example.grpc.EmptyProtos; | ||
import io.vertx.example.grpc.VertxEmptyPingPongServiceGrpc; | ||
import io.vertx.example.grpc.VertxEmptyPingPongServiceGrpcClient; | ||
import io.vertx.grpc.client.GrpcClient; | ||
import io.vertx.grpc.client.GrpcClientChannel; | ||
|
||
/* | ||
* @author <a href="mailto:[email protected]">Paulo Lopes</a> | ||
|
@@ -22,10 +21,9 @@ public void start() { | |
|
||
// Create the channel | ||
GrpcClient client = GrpcClient.client(vertx); | ||
GrpcClientChannel channel = new GrpcClientChannel(client, SocketAddress.inetSocketAddress(8080, "localhost")); | ||
|
||
// Get a stub to use for interacting with the remote service | ||
VertxEmptyPingPongServiceGrpc.EmptyPingPongServiceVertxStub stub = VertxEmptyPingPongServiceGrpc.newVertxStub(channel); | ||
VertxEmptyPingPongServiceGrpcClient stub = new VertxEmptyPingPongServiceGrpcClient(client, SocketAddress.inetSocketAddress(8080, "localhost")); | ||
|
||
// Make a request | ||
EmptyProtos.Empty request = EmptyProtos.Empty.newBuilder().build(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
package io.vertx.example.grpc.helloworld; | ||
|
||
import io.grpc.examples.helloworld.HelloRequest; | ||
import io.grpc.examples.helloworld.VertxGreeterGrpc; | ||
import io.grpc.examples.helloworld.VertxGreeterGrpcClient; | ||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.Launcher; | ||
import io.vertx.core.net.SocketAddress; | ||
import io.vertx.grpc.client.GrpcClient; | ||
import io.vertx.grpc.client.GrpcClientChannel; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Julien Viet</a> | ||
|
@@ -20,8 +19,7 @@ public static void main(String[] args) { | |
@Override | ||
public void start() { | ||
GrpcClient client = GrpcClient.client(vertx); | ||
GrpcClientChannel channel = new GrpcClientChannel(client, SocketAddress.inetSocketAddress(8080, "localhost")); | ||
VertxGreeterGrpc.GreeterVertxStub stub = VertxGreeterGrpc.newVertxStub(channel); | ||
VertxGreeterGrpcClient stub = new VertxGreeterGrpcClient(client, SocketAddress.inetSocketAddress(8080, "localhost")); | ||
HelloRequest request = HelloRequest.newBuilder().setName("Julien").build(); | ||
stub.sayHello(request).onComplete(asyncResponse -> { | ||
if (asyncResponse.succeeded()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,11 @@ | |
|
||
import io.grpc.examples.helloworld.HelloReply; | ||
import io.grpc.examples.helloworld.HelloRequest; | ||
import io.grpc.examples.helloworld.VertxGreeterGrpc; | ||
import io.grpc.examples.helloworld.VertxGreeterGrpcServer; | ||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.Launcher; | ||
import io.vertx.grpc.server.GrpcServer; | ||
import io.vertx.grpc.server.GrpcServiceBridge; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Julien Viet</a> | ||
|
@@ -20,7 +19,7 @@ public static void main(String[] args) { | |
|
||
@Override | ||
public void start() { | ||
VertxGreeterGrpc.GreeterVertxImplBase service = new VertxGreeterGrpc.GreeterVertxImplBase() { | ||
VertxGreeterGrpcServer.GreeterApi service = new VertxGreeterGrpcServer.GreeterApi() { | ||
@Override | ||
public Future<HelloReply> sayHello(HelloRequest request) { | ||
System.out.println("Hello " + request.getName()); | ||
|
@@ -30,9 +29,9 @@ public Future<HelloReply> sayHello(HelloRequest request) { | |
|
||
// Create the server | ||
GrpcServer rpcServer = GrpcServer.server(vertx); | ||
GrpcServiceBridge | ||
.bridge(service) | ||
.bind(rpcServer); | ||
|
||
// Bind the service | ||
service.bind_sayHello(rpcServer); | ||
|
||
// start the server | ||
vertx.createHttpServer().requestHandler(rpcServer).listen(8080) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,8 @@ | |
import io.vertx.core.Launcher; | ||
import io.vertx.core.net.SocketAddress; | ||
import io.vertx.example.grpc.Messages; | ||
import io.vertx.example.grpc.VertxPingPongServiceGrpc; | ||
import io.vertx.example.grpc.VertxPingPongServiceGrpcClient; | ||
import io.vertx.grpc.client.GrpcClient; | ||
import io.vertx.grpc.client.GrpcClientChannel; | ||
|
||
/* | ||
* @author <a href="mailto:[email protected]">Paulo Lopes</a> | ||
|
@@ -22,10 +21,9 @@ public void start() { | |
|
||
// Create the channel | ||
GrpcClient client = GrpcClient.client(vertx); | ||
GrpcClientChannel channel = new GrpcClientChannel(client, SocketAddress.inetSocketAddress(8080, "localhost")); | ||
|
||
// Get a stub to use for interacting with the remote service | ||
VertxPingPongServiceGrpc.PingPongServiceVertxStub stub = VertxPingPongServiceGrpc.newVertxStub(channel); | ||
VertxPingPongServiceGrpcClient stub = new VertxPingPongServiceGrpcClient(client, SocketAddress.inetSocketAddress(8080, "localhost")); | ||
|
||
// Make a request | ||
Messages.SimpleRequest request = Messages.SimpleRequest.newBuilder().setFillUsername(true).build(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
package io.vertx.example.grpc.pingpong; | ||
|
||
import io.vertx.core.AbstractVerticle; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.Launcher; | ||
import io.vertx.example.grpc.Messages; | ||
import io.vertx.example.grpc.VertxPingPongServiceGrpc; | ||
import io.vertx.example.grpc.PingPongServiceGrpc; | ||
import io.vertx.grpc.server.GrpcServer; | ||
import io.vertx.grpc.server.GrpcServiceBridge; | ||
|
||
/* | ||
* @author <a href="mailto:[email protected]">Paulo Lopes</a> | ||
|
@@ -20,19 +18,17 @@ public static void main(String[] args) { | |
@Override | ||
public void start() { | ||
|
||
// The rpc service | ||
VertxPingPongServiceGrpc.PingPongServiceVertxImplBase service = new VertxPingPongServiceGrpc.PingPongServiceVertxImplBase() { | ||
@Override | ||
public Future<Messages.SimpleResponse> unaryCall(Messages.SimpleRequest request) { | ||
return Future.succeededFuture(Messages.SimpleResponse.newBuilder().setUsername("Paulo").build()); | ||
} | ||
}; | ||
|
||
// Create the server | ||
GrpcServer rpcServer = GrpcServer.server(vertx); | ||
GrpcServiceBridge | ||
.bridge(service) | ||
.bind(rpcServer); | ||
|
||
// | ||
rpcServer.callHandler(PingPongServiceGrpc.getUnaryCallMethod(), request -> { | ||
request | ||
.last() | ||
.onSuccess(msg -> { | ||
request.response().end(Messages.SimpleResponse.newBuilder().setUsername("Paulo").build()); | ||
}); | ||
}); | ||
|
||
// start the server | ||
vertx.createHttpServer().requestHandler(rpcServer).listen(8080) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.