Channels #57
-
Hi Ben. I love your clear and simple expositions. They've helped me a lot. I found myself going back into the finished parts of the project I'm working on after discovering your posts. Thank you for always keeping clarity and performance in mind! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Thanks! I'm glad to hear it's been helpful. As for channels, I generally don't use them from an application development perspective. I find they're difficult to use and clean up from easily and there's usually better concurrency constructs at the application level. I do use them sometimes for lower level code but many times I'll just use a mutex or wait group or some of the constructs in the For application development, I find I use Folks also tend to use channels as a form of queue but their main downside is that they lack persistence. For example, you might want to run a "job" of some sort and if you queue it in a channel then it won't persist across restarts. Many of the uses of channels at the application level end up being moved to something like Kafka or a message queue server that's more robust. |
Beta Was this translation helpful? Give feedback.
-
Wow! Thank you very much for this clear reply. I'll look more closely into |
Beta Was this translation helpful? Give feedback.
Thanks! I'm glad to hear it's been helpful. As for channels, I generally don't use them from an application development perspective. I find they're difficult to use and clean up from easily and there's usually better concurrency constructs at the application level. I do use them sometimes for lower level code but many times I'll just use a mutex or wait group or some of the constructs in the
sync
package.For application development, I find I use
errgroup
a lot. I find a lot of concurrency at the application level is for fanning out calls in parallel anderrgroup
fits that pretty well. Channels can also be used for throttling but there's other higher level constructs likesemaphore
or a t…