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

An example

Install grpcnode:

npm i -g grpcnode

You can start a quick “Star Friends” server, from the example repo:

git clone https://github.com/backstopmedia/gRPC-book-example.git
cd gRPC-book-example/examples/nodejs
npm i
npm start

grpcnode server

You can use it to get a list of available RPCs, based on the proto:

grpcnode client ls -I ../../proto sfapi.proto

grpcnode ls

You can run the GetPerson RPC by JSON-encoding your request:

grpcnode client run -I ../../proto sfapi.proto -c '/sfapi.v1.Starfriends/GetPerson({"id":"SyAbJp35ViM"})'

There is also a HTTP/JSON gateway running https://github.com/konsumer/grpc-dynamic-gateway, so you can use your favorite way of messing with JSON-servers (curl, postman, etc.).

grpcnode ls