1 Star 0 Fork 2

githubsync/vertx-examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
README.adoc 5.64 KB
一键复制 编辑 原始数据 按行查看 历史
Julien Viet 提交于 2022-05-24 20:36 +08:00 . New gRPC examples

Vert.x gRPC examples

Here you will find examples demonstrating Vert.x gRPC in action.

Dependencies required

To use Vert.x gRPC in your own Maven or Gradle project add the following dependency

Group ID: io.vertx
Artifact ID: vertx-grpc

You will need to use the com.google.protobuf plugin to compile the .proto files. These examples use the io.vertx:vertx-grpc-protoc-plugin plugin that creates server and stub classes for Vert.x.

Each example shows how to use the gRPC request/response API and how to use the stub API.

The protobuf compiler is available for Maven or Gradle and is OS dependant.

Empty exchanges

This example show how to handle RPC calls that do not receive or return data.

Ping Pong exchanges

This example show how to handle RPC calls that send a single object and receive a single object.

Consumer exchange

This example show how to handle RPC calls that do receive an arbitrary stream of response objects.

Producer exchange

This example show how to handle RPC calls that do sends an arbitrary stream of request objects.

Conversational exchange

This example shows how to handle arbitrary streams of request and response objects.

Hello World example

This example is adapted from the gRPC examples.

It shows a simple gRPC service that invokes a service that takes takes an HelloRequest string wrapper and returns an HelloReply string wrapper.

The gRPC service extends the VertxGreeterGrpc.GreeterImplBase generated class and implements the service logic.

The gRPC client creates an instance of the VertxGreeterGrpc.newVertxStub generated class and then use it to invoke the service.

You can run the server and then run the client.

You can read more about it on the gRPC website

SSL example

This example is the Hello World example with SSL configuration.

It shows a simple gRPC service that invokes a service that takes takes an HelloRequest string wrapper and returns an HelloReply string wrapper. The communication uses SSL.

The gRPC service extends the VertxGreeterGrpc.GreeterImplBase generated class and implements the service logic.

The gRPC client creates an instance of the VertxGreeterGrpc.newVertxStub generated class and then use it to invoke the service.

You can run the server and then run the client.

Route Guide example

This example is adapted from the gRPC examples.

This example shows the various kind of gRPC service calls:

  • simple RPC

  • server-side streaming RPC

  • client-side streaming RPC

  • bidirectional streaming RPC

You can run the server and then run the client.

You can read more about it on the gRPC website

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/githubsync/vertx-examples.git
git@gitee.com:githubsync/vertx-examples.git
githubsync
vertx-examples
vertx-examples
4.x

搜索帮助