Skip to content

Commit ee9a263

Browse files
committed
Add gRPC reflection service + documentation on how to use it
1 parent 38cec8c commit ee9a263

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

jpms-examples/README.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,23 @@ Or use the launcher:
119119
./target/maven-jlink/default/bin/grpc-server
120120
----
121121

122+
You can use https://github.com/fullstorydev/grpcurl[gRPCurl] to interact with the server and its hosted services:
123+
124+
[source,shell]
125+
----
126+
> grpcurl -plaintext localhost:8080 list
127+
grpc.reflection.v1.ServerReflection
128+
helloworld.Greeter
129+
130+
> grpcurl -plaintext localhost:8080 list helloworld.Greeter
131+
helloworld.Greeter.SayHello
132+
133+
> grpcurl -plaintext -d '{"name":"Julien"}' localhost:8080 helloworld.Greeter.SayHello
134+
{
135+
"message": "Hello Julien"
136+
}
137+
----
138+
122139
== Native transports
123140

124141
A simple link:src/main/java/io/vertx/example/jpms/http2/Server.java[HTTP server] running with Netty native transports kqueue/epoll/io_uring.

jpms-examples/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
</exclusion>
8181
</exclusions>
8282
</dependency>
83+
<dependency>
84+
<groupId>io.vertx</groupId>
85+
<artifactId>vertx-grpc-reflection</artifactId>
86+
</dependency>
8387
<dependency>
8488
<groupId>com.google.protobuf</groupId>
8589
<artifactId>protobuf-java</artifactId>

jpms-examples/src/main/java/io/vertx/example/jpms/grpc/Server.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.vertx.example.jpms.grpc.helloworld.GreeterGrpcService;
88
import io.vertx.example.jpms.grpc.helloworld.HelloReply;
99
import io.vertx.example.jpms.grpc.helloworld.HelloRequest;
10+
import io.vertx.grpc.reflection.ReflectionService;
1011
import io.vertx.grpc.server.GrpcServer;
1112

1213
public class Server extends VerticleBase {
@@ -33,6 +34,9 @@ public Future<HelloReply> sayHello(HelloRequest request) {
3334
};
3435
grpcServer.addService(service);
3536

37+
// Add reflection service
38+
grpcServer.addService(ReflectionService.v1());
39+
3640
HttpServer server = vertx
3741
.createHttpServer(
3842
new HttpServerOptions()

jpms-examples/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
// SQL client template
3232
requires io.vertx.sql.client.templates;
33+
requires io.vertx.grpc.reflection;
3334

3435
exports io.vertx.example.jpms.sqlclient;
3536
exports io.vertx.example.jpms.sqltemplate;

0 commit comments

Comments
 (0)