This recipe demonstrates creating groups of worker pools and connecting them together to form a pipeline. For this recipe, we link together two pools, but the pattern can be used for much more complex operations, similar to middleware.
Worker pools can be useful for keeping workers relatively simple and to also further control concurrency. For example, it may be useful to serialize logging while parallelizing other operations. It may also be useful to have a smaller pool for more expensive operations so that you don't overload machine resources.
How to do it...
These steps cover writing and running your application:
- From your Terminal or console application,createa new directory called~/projects/go-programming-cookbook/chapter10/pipelineand navigate to it.
- Run the following command:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition...