-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathClient.java
More file actions
39 lines (32 loc) · 1.13 KB
/
Client.java
File metadata and controls
39 lines (32 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package io.vertx.example.grpc.producer;
import io.vertx.core.Future;
import io.vertx.core.VerticleBase;
import io.vertx.core.net.SocketAddress;
import io.vertx.example.grpc.Messages;
import io.vertx.example.grpc.ProducerServiceGrpcClient;
import io.vertx.grpc.client.GrpcClient;
import io.vertx.launcher.application.VertxApplication;
/*
* @author <a href="mailto:plopes@redhat.com">Paulo Lopes</a>
*/
public class Client extends VerticleBase {
public static void main(String[] args) {
VertxApplication.main(new String[]{Client.class.getName()});
}
private GrpcClient client;
@Override
public Future<?> start() {
// Create the client
client = GrpcClient.client(vertx);
// Call the remote service
return client.request(SocketAddress.inetSocketAddress(8080, "localhost"), ProducerServiceGrpcClient.StreamingInputCall)
.compose(request -> {
for (int i = 0; i < 10; i++) {
request.write(Messages.StreamingInputCallRequest.newBuilder().build());
}
request.end();
return request.response();
})
.onSuccess(response -> System.out.println("Server replied OK"));
}
}