content: remove Provider.Reader

After some analysis, it was found that Content.Reader was generally
redudant to an io.ReaderAt. This change removes `Content.Reader` in
favor of a `Content.ReaderAt`. In general, `ReaderAt` can perform better
over interfaces with indeterminant latency because it avoids remote
state for reads. Where a reader is required, a helper is provided to
convert it into an `io.SectionReader`.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-07-27 19:07:58 -07:00
parent 1f04eddad1
commit 8be340e37b
19 changed files with 105 additions and 152 deletions

View File

@@ -210,13 +210,13 @@ func (c *Converter) fetchBlob(ctx context.Context, desc ocispec.Descriptor) erro
// TODO: Check if blob -> diff id mapping already exists
// TODO: Check if blob empty label exists
r, err := c.contentStore.Reader(ctx, desc.Digest)
ra, err := c.contentStore.ReaderAt(ctx, desc.Digest)
if err != nil {
return err
}
defer r.Close()
defer ra.Close()
gr, err := gzip.NewReader(r)
gr, err := gzip.NewReader(content.NewReader(ra))
if err != nil {
return err
}