Book Image

Mastering Concurrency in Go

By : Nathan Kozyra
Book Image

Mastering Concurrency in Go

By: Nathan Kozyra

Overview of this book

<p>This book will take you through the history of concurrency, how Go utilizes it, how Go differs from other languages, and the features and structures of Go's concurrency core. Each step of the way, the book will present real, usable examples with detailed descriptions of the methodologies used. By the end, you will feel comfortable designing a safe, data-consistent, high-performance concurrent application in Go.</p> <p>The focus of this book is on showing you how Go can be used to program high-performance, robust concurrent programs with Go's unique form of multithreading, which employs goroutines that communicate and synchronize across channels. Designed for any curious developer or systems administrator with an interest in fast, non-blocking, and resource-thrifty systems applications, this book is an invaluable resource to help you understand Go's powerful concurrency focus.</p>
Table of Contents (17 chapters)
Mastering Concurrency in Go
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Building workers


Earlier in this book, we talked about concurrency patterns and a bit about workers. We even brought the workers concept into play in the previous chapter, when we were building our logging systems.

Truly speaking, "worker" is a fairly generic and ambiguous concept, not just in Go, but in general programming and development. In some languages, it's an object/instantiated class, and in others it's a concurrent actor. In functional programming languages, worker is a graduated function return passed to another.

If we go back to the preface, we will see that we have literally used the Go gopher as an example of a worker. In short, a worker is something more complex than a single function call or programmatic action that will perform a task one or more times.

So why are we talking about it now? When we build our channels, we are creating a mechanism to do work. When we have a struct or an interface, we're combining methods and values at a single place, and then doing work using that...