lo
lo copied to clipboard
Add concurrency limit option to package `lo/parallel`
Sometimes if the collection is too big, it will make too many goroutines in one time when using parallel methods. That will significantly increase resource usage, especially when the iteratee function is computationally-Intensive, io-Intensive, or both.
An example that requests every URL in a huge list, will start so many requests at the same time:
hugeUrlList := []string{ /*...*/ }
parallel.ForEach(hugeUrlList, request)
I think there should have an option to set the max concurrency count, which means up to configured number iteratee calling at the same time:
hugeUrlList := []string{ /*...*/ }
parallel.ForEach(hugeUrlList, request, parallel.Option().Concurrency(100))
I will enjoy implementing it.
This is already implemented in #37