Streaming from the Server to the Client with gRPC
Like any RPC system, gRPC is primarily focused around allowing methods to be called remotely. To facilitate this functionality, there are four primary types of RPCs that can be specified with gRPC. In the prior tutorial, we took a look at unary RPC services exclusively. These are the most basic forms of RPC services that can be defined with gRPC. In this tutorial however, we add on a server streaming RPC service in conjunction with a unary RPC service.
In this image, are the two main services for our Chat Application. The
CreateStream service is the server streaming service, denoted by the
stream keyword in the returns statement. When a client connects to the server, the server will open a stream to the client. This will then allow the server to stream any received messages to the client and any other active clients which are also connected.
Using Docker Containers for Go and gRPC Microservices
Docker is a revolutionary tool, that was also build with Go, that makes it easier to create, deploy and run applications inside of containers. A container is a small environment detached from the major Operating System which contains all of the tools needed to build and execute the enclosed application. In this way, docker is a bit like a virtual machine; however, unlike a virtual machine, docker doesn’t create an entire virtual operating system.