Recipe 49Using a Worker Pool with Channels

Task

As part of the site reliability engineering (SRE) team, you’re working on a system to monitor your services. Ali, the SRE team lead, assigns you the following issue:

We’d like to monitor web servers. You should report the HTTP status code and how much time it took to read the data sent from the server. Since there are many sites to monitor, please limit the amount of concurrency units you are using.

After a discussion with the team, you decide to give the user the option to specify how many units of concurrency (goroutines) they want.

Looking at the code, you find there’s already a siteInfo function:

 // Info is information on site.
 type​ Info ​struct​ { ...

Get Effective Go Recipes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.