Commit e5644bc7 authored by Steven Allen's avatar Steven Allen

query: avoid a goroutine in ResultsWithEntries

parent 0f659c79
......@@ -245,22 +245,19 @@ func ResultsWithProcess(q Query, proc func(goprocess.Process, chan<- Result)) Re
// ResultsWithEntries returns a Results object from a list of entries
func ResultsWithEntries(q Query, res []Entry) Results {
b := NewResultBuilder(q)
// go consume all the entries and add them to the results.
b.Process.Go(func(worker goprocess.Process) {
for _, e := range res {
select {
case b.Output <- Result{Entry: e}:
case <-worker.Closing(): // client told us to close early
return
i := 0
return ResultsFromIterator(q, Iterator{
Next: func() (Result, bool) {
if i >= len(res) {
return Result{}, false
}
}
return
next := res[i]
i++
return Result{Entry: next}, true
},
})
}
go b.Process.CloseAfterChildren()
return b.Results()
}
func ResultsReplaceQuery(r Results, q Query) Results {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment