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

Streams

A stream is a bidirectional flow of bytes that in a given connection may carry one or more messages. Each stream is identified by an integer that will be written on the header of any frame.

Note that in a single TCP connection, several streams may be active concurrently at the same time.

Streams have lifecycles and they are represented by transitions among states. These are all the possible states:

  • Idle: Initial state for any opened stream.
  • Open: State where both peers may send or receive frames at any moment.
  • Reserved: One of the peers, having the stream in Idle state, sent a PUSH_PROMISE frame in order for the server to begin to push messages to the client.
  • Half Closed: One of the peers finished to send frames.
  • Closed: Both peers agreed to terminate the connection.

Here you can see the workflow:

workflow