~ecs/hq

05e89aaebceb0242aaa43c75277e0b2cc05a11a0 — Ember Sawady 2 months ago 6c304de
Improve multi error handling
1 files changed, 17 insertions(+), 3 deletions(-)

M main.go
M main.go => main.go +17 -3
@@ 103,11 103,25 @@ func Exec(e Expr, ins []<-chan Datum, out chan Datum) error {
		}()
		go func() {
			// Go's type system is fucking dumb
			var inputs []<-chan Datum
			var ins []<-chan Datum
			for _, mid := range mids {
				inputs = append(inputs, mid)
				ins = append(ins, mid)
			}
			errs <- Exec(e.Multi.Out, inputs, out)
			err := Exec(e.Multi.Out, ins, out)
			for ch, d := Select(ins); true; ch, d = Select(ins) {
				if d != nil && !d.End {
					continue
				}
				for i, c := range ins {
					if c == ch {
						ins = append(ins[:i], ins[i+1:]...)
					}
				}
				if len(ins) == 0 {
					break
				}
			}
			errs <- err
		}()
		err := <-errs
		for range e.Multi.Cmds {