Using gRPC
gRPC is an RPC framework originally invented at Google. Unlike Thrift, gRPC makes use of existing technologies, specifically protocol buffers, for its IDL and HTTP/2 for its transport layer. After having completed the previous recipe, aspects of gRPC will feel similar to aspects of Thrift. Instead of the Thrift IDL, types and services are defined in a .proto file. The .proto file can then be used to generate code using the protocol buffer's compiler.
How to do it...
- Create a new Gradle/Java project with the following
build.gradlefile. Of note here is that we're installing and configuring theprotobufGradle plugin, which will allow us to generate code fromprotobuffiles using Gradle, and we're listing the requiredprotobuflibraries as dependencies. Finally, we have to tell our IDE where to look for generated classes:
group 'com.packtpub.microservices'
version '1.0-SNAPSHOT'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com...