Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

Bi-directional streaming RPCs

The last RPC mode that we will explore is bi-directional streaming. This mode combines client- and server-side streaming and provides us with two independent channels where the client and server can asynchronously publish and consume messages.

To understand how this mode works, let's examine the definition for an asynchronous Echo service:

message EchoMessage {  string message = 1;}service EchoService {  rpc Echo (stream EchoMessage) returns (stream EchoMessage);}

The server-side logic for the echo service is not that interesting. As shown in the following code snippet, the server runs a for loop where it reads the next message from the client and echoes it back. The server's for loop keeps executing until the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content