@@ -150,12 +150,6 @@ type Results interface {
150
150
NextSync () (Result , bool ) // blocks and waits to return the next result, second parameter returns false when results are exhausted
151
151
Rest () ([]Entry , error ) // waits till processing finishes, returns all entries at once.
152
152
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
159
153
}
160
154
161
155
// results implements Results
@@ -186,10 +180,6 @@ func (r *results) Rest() ([]Entry, error) {
186
180
return es , nil
187
181
}
188
182
189
- func (r * results ) Process () goprocess.Process {
190
- return r .proc
191
- }
192
-
193
183
func (r * results ) Close () error {
194
184
return r .proc .Close ()
195
185
}
@@ -210,15 +200,15 @@ func (r *results) Query() Query {
210
200
// an early close signal from the client.
211
201
type ResultBuilder struct {
212
202
Query Query
213
- Process goprocess.Process
203
+ process goprocess.Process
214
204
Output chan Result
215
205
}
216
206
217
207
// Results returns a Results to to this builder.
218
208
func (rb * ResultBuilder ) Results () Results {
219
209
return & results {
220
210
query : rb .Query ,
221
- proc : rb .Process ,
211
+ proc : rb .process ,
222
212
res : rb .Output ,
223
213
}
224
214
}
@@ -235,7 +225,7 @@ func NewResultBuilder(q Query) *ResultBuilder {
235
225
Query : q ,
236
226
Output : make (chan Result , bufSize ),
237
227
}
238
- b .Process = goprocess .WithTeardown (func () error {
228
+ b .process = goprocess .WithTeardown (func () error {
239
229
close (b .Output )
240
230
return nil
241
231
})
@@ -248,7 +238,7 @@ func NewResultBuilder(q Query) *ResultBuilder {
248
238
// DEPRECATED: This iterator is impossible to cancel correctly. Canceling it
249
239
// will leave anything trying to write to the result channel hanging.
250
240
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 ) {
252
242
for {
253
243
select {
254
244
case <- worker .Closing (): // client told us to close early
@@ -265,20 +255,16 @@ func ResultsWithChan(q Query, res <-chan Result) Results {
265
255
}
266
256
}
267
257
}
268
- })
269
- }
258
+ }
270
259
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 {
274
260
b := NewResultBuilder (q )
275
261
276
262
// 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 ) {
278
264
proc (worker , b .Output )
279
265
})
280
266
281
- go b .Process .CloseAfterChildren () //nolint
267
+ go b .process .CloseAfterChildren () //nolint
282
268
return b .Results ()
283
269
}
284
270
@@ -378,11 +364,6 @@ func (r *resultsIter) Rest() ([]Entry, error) {
378
364
return es , nil
379
365
}
380
366
381
- func (r * resultsIter ) Process () goprocess.Process {
382
- r .useLegacyResults ()
383
- return r .legacyResults .Process ()
384
- }
385
-
386
367
func (r * resultsIter ) Close () error {
387
368
if r .legacyResults != nil {
388
369
return r .legacyResults .Close ()
@@ -403,7 +384,7 @@ func (r *resultsIter) useLegacyResults() {
403
384
b := NewResultBuilder (r .query )
404
385
405
386
// 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 ) {
407
388
defer r .close ()
408
389
for {
409
390
e , ok := r .next ()
@@ -418,7 +399,7 @@ func (r *resultsIter) useLegacyResults() {
418
399
}
419
400
})
420
401
421
- go b .Process .CloseAfterChildren () //nolint
402
+ go b .process .CloseAfterChildren () //nolint
422
403
423
404
r .legacyResults = b .Results ().(* results )
424
405
}
0 commit comments