Skip to content

Commit

Permalink
fix: add reader get part retries
Browse files Browse the repository at this point in the history
  • Loading branch information
jobstoit committed Apr 26, 2024
1 parent ea4e5ad commit 55e38bb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion feature/s3/manager/reader.go
Expand Up @@ -23,6 +23,7 @@ type ObjectReader struct {
chunkSize int64
concurrency int
clientOptions []func(*s3.Options)
partRetries int
input *s3.GetObjectInput
}

Expand All @@ -34,6 +35,7 @@ func (d *Downloader) NewReader(ctx context.Context, input *s3.GetObjectInput) io
input: input,
chunkSize: d.PartSize,
concurrency: d.Concurrency,
partRetries: d.PartBodyMaxRetries,
clientOptions: d.ClientOptions,
}

Expand Down Expand Up @@ -176,5 +178,14 @@ func (r *ObjectReader) getObject(ctx context.Context, start, end int64) (*s3.Get
copyInput := *r.input
copyInput.Range = &byteRange

return r.s3.GetObject(ctx, &copyInput, r.clientOptions...)
var output *s3.GetObjectOutput
var err error
for i := 0; i < r.partRetries; i++ {
output, err = r.s3.GetObject(ctx, &copyInput, r.clientOptions...)
if err == nil {
return output, nil
}
}

return output, err
}

0 comments on commit 55e38bb

Please sign in to comment.