March 2020
Intermediate to advanced
406 pages
8h 39m
English
Go's buffered channels are a perfect example of a worker queue. As we learned in Chapter 3, Understanding Concurrency, buffered channels are channels that have a bounded size. They are typically more performant than their unbounded counterpart. They are useful for retrieving values from an explicit number of goroutines you've launched. Because they are first in first out (FIFO) queuing mechanisms, they can be effectively used as a fixed-size queuing mechanism, and we can process requests in the order that they came in. We can write a simple job queue using a buffered channel. Let's take a look:
package ...
Read now
Unlock full access