4 ms·
Not blocking the caller is usually bad, the program can run out of memory if the producer is much faster than the consumers. Also, in more realistic scenarios "
by rthinker 6y ago
Not blocking the caller is usually bad, the program can run out of memory if the producer is much faster than the consumers.
Also, in more realistic scenarios "process" can error, one would want to use the errgroup package.
- knorker 6y agoI presented both solutions because "it depends". Though I agree with "usually". Yes, if in doubt then block the caller. I mainly provided it as an example because the article had it as an explicit requirement. You're right about errgroup. One can fit only so much in a HN comment. And I didn't want to distract by making it look like "no, you should use my favourite library instead". But again it depends. If an error is handled by doing log.Fatal(), then there's no point in using errgroup. I'm also not passing ctx, which much (most?) nontrivial code should pass.