A few years back I have been exploring solutions for the in-process gRPC pattern in Go, for the Thanos project . Recently, a friend and a Thanos maintainer Filip refreshed the initial Thanos solution with the new Go 1.23 iterators .
This created a perfect opportunity to share, in a co-authored blog post, what Filip and I learned about the new iterators, new coroutines (not goroutines!) and what options you have for the production in-process gRPC logic. Given our limited time, why not explore all in one blog post, what could go wrong? (:
gRPC is a popular open-source Remote Procedure Call (RPC) framework with a few unique elements like a tight protobuf integration, HTTP/2 use and a native bi-directional streaming capabilities. Before we move to the advanced in-process gRPC problem space, let’s define an example gRPC service that “lists” strings in form a gRPC server stream:
With the help of protoc or buf (invoked like this ) and Go and gRPC plugins we can generate Go client and server interfaces (with the corresponding stream interfaces) that looks like this: