Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Why
Handling context cancellation in a select with the channel operations is, strictly speaking, a bug fix (context should be available as a lever to cancel blocked operations), but practically isn't used here.
Returning an error from Process after Stop is a behaviour change that is similarly theoretical (if the job is always stopped, and Process is never called again before Stop). But it is an improvement: before, if Stop is called then there is the possibility that, if all the workers are stopped and Process is called again, the chunk is left in the channel until the program exits, or potentially the queue fills up and the goroutine managing the streamer blocks forever. Now, Process at least returns an error.
This also means that we can be more explicit about closing the queue and then actually wait for for the workers to finish, rather than waiting for current work to finish before yeeting nil several times into the (buffered) queue channel and not actually waiting them to shut down (this always seemed weird and backwards to me).
Notes
Note that this does not enable log limit enforcement (yet).