This commit is contained in:
Dhruv Sringari
2022-02-17 14:22:46 -08:00
parent 7f6fa2c8a5
commit 009bb85d8d
2 changed files with 6 additions and 9 deletions
+3 -5
View File
@@ -66,11 +66,9 @@ func (rws *ReaderWithStats) Start(updateFunc func(ReadStats)) {
}()
}
// Close is equivalent to Stop
func (rws *ReaderWithStats) Close() error {
return rws.Stop()
}
// Stop "closes" ReaderWithStats. Occasionally, we might pass this ReaderWithStats as the body of
// a http.Request. Since http.Request will close the body if it is an io.Closer, we can't have ReaderWithStats conform
// to io.Closer. We want full control over the Start and Stop of ReaderWithStats.
func (rws *ReaderWithStats) Stop() error {
close(rws.closeCh)
+3 -4
View File
@@ -17,7 +17,6 @@ package pull
import (
"context"
"errors"
"io"
"github.com/cenkalti/backoff"
"golang.org/x/sync/errgroup"
@@ -86,8 +85,8 @@ func mapTableFiles(tblFiles []nbs.TableFile) ([]string, map[string]nbs.TableFile
return fileIds, fileIDtoTblFile, fileIDtoNumChunks
}
func CloseWithErr(c io.Closer, err *error) {
e := c.Close()
func stopWithErr(stats *iohelp.ReaderWithStats, err *error) {
e := stats.Stop()
if *err == nil && e != nil {
*err = e
}
@@ -144,7 +143,7 @@ func clone(ctx context.Context, srcTS, sinkTS nbs.TableFileStore, eventCh chan<-
return err
}
rdStats := iohelp.NewReaderWithStats(rd, int64(contentLength))
defer CloseWithErr(rdStats, &err)
defer stopWithErr(rdStats, &err)
rdStats.Start(func(s iohelp.ReadStats) {
report(TableFileEvent{