4 ms·
Well writen. Will recommend to all newcomers from other languages. As for uncovered topics or part 2 - long running Go channels can be a nightmare. You need t
by adeptima 2y ago
Well writen. Will recommend to all newcomers from other languages.
As for uncovered topics or part 2 - long running Go channels can be a nightmare.
You need to implement kind of observability for them.
You must find the way to stop/run again/upgrade and even version payload to handle your channels/goroutine.
Common problem with channels overuse is so called goroutine leaks. Happens more often than most devs think. Especially, if lib writers initiate goroutines in init() to maintain cache or do some background cleanup job. It's good to scan all used packages for such surprises.
You might also find concepts like "durable execution" or "workflow" engines down the road.
- Intermernet 2y agoOne pattern for long running channels is to have another polling / heartbeat channel on the goroutine. This is often redundant as you can achieve the basic functionality with contexts, but it can be useful when you need to implement some reporting, or you need to implement more advanced load balancing or back off strategies.