Book Image

Practical gRPC

By : Joshua B. Humphries, David Konsumer, David Muto, Robert Ross, Carles Sistare
Book Image

Practical gRPC

By: Joshua B. Humphries, David Konsumer, David Muto, Robert Ross, Carles Sistare

Overview of this book

While building systems that contain several components, you need a framework that is fast and has minimal network overhead. gRPC is one such open-source tool that is quickly becoming popular and gaining popularity with programmers. Practical gRPC introduces you to gRPC and explains how it compares and contrasts with similar technologies. You’ll be introduced to key technologies such as Protocol Buffers, and work your way up from basic gRPC usage, all the way through to its more advanced capabilities. You’ll learn the best practices for defining and evolving your gRPC APIs, and discover how different tools can be leveraged to get the most out of gRPC and even extend it. By the end of this book, you'll have all the information you need to get started building systems with gRPC.
Table of Contents (13 chapters)
11
11. Extending gRPC services

Services

The services implemented in gRPC are defined as RPCs (Remote Procedure Calls) in the .proto file.

RPC was designed for developers to be able to execute a procedure in their source code, without caring about its execution. You can focus your efforts on coding the procedure, without worrying about serialization, communication, or security.

A service example can be defined as follows:

syntax = "proto2";

service Starwars {

    rpc GetFilm(GetFilmRequest) returns (GetFilmResponse);

}

Thanks to this definition, the protocol buffer compiler will generate the service interface code and stubs (client and server side) suiting the chosen language. You can create your own RPC system, or you can use gRPC.

Importing other proto files

As mentioned earlier in the Nested Messages section, you can create messages that may be used inside other messages.

A flatter form of doing the same thing to avoid nesting to the infinity would be creating every single message on the root level...