News for hackers. Stuff that matters.
Re:Building a Streaming Platform in Go for Postgres by foobiekr on Monday November 06, 2023 @08:44PM (#38172073)
exactly.

you can't abstract over channels easily unless you're missing the point of channels.

Re:Building a Streaming Platform in Go for Postgres by earthboundkid on Tuesday November 07, 2023 @08:59AM (#38176754)
I think the rule is: don't use a channel unless at some point you need a select with 2+ branches. The context.Done is a case in point. You're not just waiting around for a context to finish. You do two things: try some network request and wait to see if the context cancels before it finishes. Because it's made to work in a select block like that, there wasn't another, better thing to use than a channel for context.Done. But for just iterating through some stream, you take a context in and return an iterator object that will do all the channel stuff internally.