Bidirectional streaming with gRPC

The main advantage of gRPC over traditional HTTP/1.1 is that it can use a single TCP connection for sending and receiving multiple messages between the server and the client. We saw the example of a money transaction previously. Another real-world use case is a GPS installed in a taxi. Here, the taxi is the client that sends its geographical points to the server along its route. Finally, the server can calculate the total fare amount depending on the time spent between points and the total distance.

Another use case is a server pushing data to a client. This is called a server push model, where a server can send a stream of results back to the client. This is different from polling, where the client creates ...

Get Hands-On RESTful Web Services with Go - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.