Skip to content

Commit 7293cbc

Browse files
committed
s3proxy: use s3util.Client directly instead of internally
1 parent 966d909 commit 7293cbc

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

s3proxy/s3proxy.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"sync"
1919
"time"
2020

21-
"github.com/aws/aws-sdk-go-v2/service/s3"
2221
"github.com/creachadair/atomicfile"
2322
"github.com/creachadair/taskgroup"
2423
"github.com/goproxy/goproxy"
@@ -53,11 +52,7 @@ type Cacher struct {
5352

5453
// S3Client is the S3 client used to read and write cache entries to the
5554
// backing store. It must be non-nil.
56-
S3Client *s3.Client
57-
58-
// S3Bucket is the name of the S3 bucket where cache entries are stored.
59-
// It must be non-empty.
60-
S3Bucket string
55+
S3Client *s3util.Client
6156

6257
// KeyPrefix, if non-empty, is prepended to each key stored into S3, with an
6358
// intervening slash.
@@ -97,7 +92,6 @@ type Cacher struct {
9792
tasks *taskgroup.Group
9893
start func(taskgroup.Task) *taskgroup.Group
9994
sema *semaphore.Weighted
100-
client *s3util.Client
10195

10296
pathError expvar.Int // errors constructing file paths
10397
getRequest expvar.Int // total number of Get requests
@@ -125,7 +119,6 @@ func (c *Cacher) init() {
125119
}
126120
c.tasks, c.start = taskgroup.New(nil).Limit(nt)
127121
c.sema = semaphore.NewWeighted(int64(nt))
128-
c.client = &s3util.Client{Client: c.S3Client, Bucket: c.S3Bucket}
129122
})
130123
}
131124

@@ -162,7 +155,7 @@ func (c *Cacher) Get(ctx context.Context, name string) (_ io.ReadCloser, oerr er
162155
}
163156
defer c.sema.Release(1)
164157

165-
obj, err := c.client.Get(ctx, c.makeKey(hash))
158+
obj, err := c.S3Client.Get(ctx, c.makeKey(hash))
166159
if errors.Is(err, fs.ErrNotExist) {
167160
c.getFaultMiss.Add(1)
168161
return nil, err
@@ -231,7 +224,7 @@ func (c *Cacher) Put(ctx context.Context, name string, data io.ReadSeeker) (oerr
231224
sctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 1*time.Minute)
232225
defer cancel()
233226

234-
if err := c.client.Put(sctx, c.makeKey(hash), f); err != nil {
227+
if err := c.S3Client.Put(sctx, c.makeKey(hash), f); err != nil {
235228
c.putS3Error.Add(1)
236229
c.logf("[s3] put %q failed: %v", name, err)
237230
} else {

0 commit comments

Comments
 (0)