nozzle/throttler

How to preemptively quit?

mgutz opened this issue · 4 comments

I want to run many func() error goroutines and stop throttling as soon as any returns an error.

Where are you receiving the channel errors? You should be able to just break out of the loop. If you can create a playground with your code, I could give you a better answer.

mgutz - The more I thought about it, the more useful I think having errors built into Throttler is. I just committed a change that requires you to send in an error with t.Done(). Then t.Throttle() returns a count of how many errors have occurred. Based on that, you can choose to break the loop. You can see the new code in action here:
http://bit.ly/throttler-docs-v2

Let me know if that solves the problem you're facing.

That's exactly what I needed. TY

Glad that works for you. Thanks for bringing it up!