Skip to content

Commit 0dab3e6

Browse files
committed
remove goprocess from api
1 parent 248ae82 commit 0dab3e6

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

query/query.go

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,6 @@ type Results interface {
150150
NextSync() (Result, bool) // blocks and waits to return the next result, second parameter returns false when results are exhausted
151151
Rest() ([]Entry, error) // waits till processing finishes, returns all entries at once.
152152
Close() error // client may call Close to signal early exit
153-
154-
// Process returns a goprocess.Process associated with these results.
155-
// most users will not need this function (Close is all they want),
156-
// but it's here in case you want to connect the results to other
157-
// goprocess-friendly things.
158-
Process() goprocess.Process
159153
}
160154

161155
// results implements Results
@@ -186,10 +180,6 @@ func (r *results) Rest() ([]Entry, error) {
186180
return es, nil
187181
}
188182

189-
func (r *results) Process() goprocess.Process {
190-
return r.proc
191-
}
192-
193183
func (r *results) Close() error {
194184
return r.proc.Close()
195185
}
@@ -210,15 +200,15 @@ func (r *results) Query() Query {
210200
// an early close signal from the client.
211201
type ResultBuilder struct {
212202
Query Query
213-
Process goprocess.Process
203+
process goprocess.Process
214204
Output chan Result
215205
}
216206

217207
// Results returns a Results to to this builder.
218208
func (rb *ResultBuilder) Results() Results {
219209
return &results{
220210
query: rb.Query,
221-
proc: rb.Process,
211+
proc: rb.process,
222212
res: rb.Output,
223213
}
224214
}
@@ -235,7 +225,7 @@ func NewResultBuilder(q Query) *ResultBuilder {
235225
Query: q,
236226
Output: make(chan Result, bufSize),
237227
}
238-
b.Process = goprocess.WithTeardown(func() error {
228+
b.process = goprocess.WithTeardown(func() error {
239229
close(b.Output)
240230
return nil
241231
})
@@ -248,7 +238,7 @@ func NewResultBuilder(q Query) *ResultBuilder {
248238
// DEPRECATED: This iterator is impossible to cancel correctly. Canceling it
249239
// will leave anything trying to write to the result channel hanging.
250240
func ResultsWithChan(q Query, res <-chan Result) Results {
251-
return ResultsWithProcess(q, func(worker goprocess.Process, out chan<- Result) {
241+
proc := func(worker goprocess.Process, out chan<- Result) {
252242
for {
253243
select {
254244
case <-worker.Closing(): // client told us to close early
@@ -265,20 +255,16 @@ func ResultsWithChan(q Query, res <-chan Result) Results {
265255
}
266256
}
267257
}
268-
})
269-
}
258+
}
270259

271-
// ResultsWithProcess returns a Results object with the results generated by the
272-
// passed subprocess.
273-
func ResultsWithProcess(q Query, proc func(goprocess.Process, chan<- Result)) Results {
274260
b := NewResultBuilder(q)
275261

276262
// go consume all the entries and add them to the results.
277-
b.Process.Go(func(worker goprocess.Process) {
263+
b.process.Go(func(worker goprocess.Process) {
278264
proc(worker, b.Output)
279265
})
280266

281-
go b.Process.CloseAfterChildren() //nolint
267+
go b.process.CloseAfterChildren() //nolint
282268
return b.Results()
283269
}
284270

@@ -378,11 +364,6 @@ func (r *resultsIter) Rest() ([]Entry, error) {
378364
return es, nil
379365
}
380366

381-
func (r *resultsIter) Process() goprocess.Process {
382-
r.useLegacyResults()
383-
return r.legacyResults.Process()
384-
}
385-
386367
func (r *resultsIter) Close() error {
387368
if r.legacyResults != nil {
388369
return r.legacyResults.Close()
@@ -403,7 +384,7 @@ func (r *resultsIter) useLegacyResults() {
403384
b := NewResultBuilder(r.query)
404385

405386
// go consume all the entries and add them to the results.
406-
b.Process.Go(func(worker goprocess.Process) {
387+
b.process.Go(func(worker goprocess.Process) {
407388
defer r.close()
408389
for {
409390
e, ok := r.next()
@@ -418,7 +399,7 @@ func (r *resultsIter) useLegacyResults() {
418399
}
419400
})
420401

421-
go b.Process.CloseAfterChildren() //nolint
402+
go b.process.CloseAfterChildren() //nolint
422403

423404
r.legacyResults = b.Results().(*results)
424405
}

0 commit comments

Comments
 (0)