This is an interesting project.
Per your request for feedback: on quick inspection, I would certainly want also a way to close down the priority channels too.
Some sort of Close() method that would stop all running goroutines from behind-the-scenes, so they do not leak, would be important for any long running process.
Maybe even use of a context.Context to effect the shutdown?
You'll quickly realize that every go channel "raw" operation (not in a select) needs to be wrapped in a select{} in order to not be deadlocked when the time to shutdown arrives (usually on a channel itself). So for instance,
for value := range heap.All() {
outCh <- value
}
would never do. One would need to allow for shutdown, something like:
for value := range heap.All() {
select {
case outCh <- value:
case <- shutdownRequestedCh:
return // and presumably run other cleanup in a defer at the top of this func
}
}
...and repeat such fixes for all other "raw" channel sends and receives.
Regards,
Jason