Writing an API
In this section, we will write the API using Protocol Buffer (Protobuf) for a payment service. If you recall, this is the piece that you haven’t yet implemented in the sample e-commerce app.
Before writing the API, let’s set up the Gradle project.
Setting up the project
The code for this chapter will contain three projects under the Chapter11
directory – the API, server, and client:
- API: This is a library project that contains the
.proto
file and its generated Java classes packaged in a JAR file. This project will generate thepayment-gateway-api-0.0.1.jar
library artifact, which you will publish in a local repository. This library will then be used in both the server and client projects. - Server: This project represents the gRPC server, which will implement the gRPC services and serve the gRPC requests.
- Client: This project contains the gRPC client, which will call the gRPC server. To kick off the inter-service communication...