@@ -3,7 +3,6 @@ package query
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "sync"
7
6
"time"
8
7
)
9
8
@@ -201,57 +200,6 @@ func (r *results) Done() <-chan struct{} {
201
200
return r .closed
202
201
}
203
202
204
- // ResultBuilder is what implementors use to construct results
205
- // Implementors of datastores and their clients must respect the
206
- // Process of the Request:
207
- //
208
- // - clients must call r.Process().Close() on an early exit, so
209
- // implementations can reclaim resources.
210
- // - if the Entries are read to completion (channel closed), Process
211
- // should be closed automatically.
212
- // - datastores must respect <-Process.Closing(), which intermediates
213
- // an early close signal from the client.
214
- type ResultBuilder struct {
215
- Query Query
216
- Output chan Result
217
-
218
- ctx context.Context
219
- cancel context.CancelFunc
220
- closed chan struct {}
221
- wg sync.WaitGroup
222
- }
223
-
224
- // Results returns a Results to to this builder.
225
- func (rb * ResultBuilder ) Results () Results {
226
- return & results {
227
- query : rb .Query ,
228
- res : rb .Output ,
229
-
230
- cancel : rb .cancel ,
231
- closed : rb .closed ,
232
- }
233
- }
234
-
235
- func NewResultBuilder (q Query ) * ResultBuilder {
236
- bufSize := NormalBufSize
237
- if q .KeysOnly {
238
- bufSize = KeysOnlyBufSize
239
- }
240
- b := & ResultBuilder {
241
- Query : q ,
242
- Output : make (chan Result , bufSize ),
243
- closed : make (chan struct {}),
244
- }
245
-
246
- b .ctx , b .cancel = context .WithCancel (context .Background ())
247
- context .AfterFunc (b .ctx , func () {
248
- b .wg .Wait ()
249
- close (b .Output )
250
- close (b .closed )
251
- })
252
- return b
253
- }
254
-
255
203
// ResultsWithContext returns a Results object with the results generated by
256
204
// the passed proc function called in a separate goroutine.
257
205
func ResultsWithContext (q Query , proc func (context.Context , chan <- Result )) Results {
0 commit comments