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

Defining abstractions for working with bi-directional gRPC streams

As we saw in Chapter 9, Communicating with the Outside World, bi-directional gRPC streams are full-duplex; the receive and send channels operate independently of each other. However, reading from a gRPC stream is a blocking operation. Therefore, to process both sides of the stream, we need to spin up some goroutines.

Another important caveat of gRPC streams is that, while we can call Recv and Send from different goroutines, calling each of these methods concurrently from different goroutines is not safe and can lead to data loss! Therefore, we need a mechanism to serialize send and receive operations on the gRPC stream. The kind of obvious Go primitives for exactly this type ...

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