@@ -18,7 +18,6 @@ import (
18
18
"sync"
19
19
"time"
20
20
21
- "github.com/aws/aws-sdk-go-v2/service/s3"
22
21
"github.com/creachadair/atomicfile"
23
22
"github.com/creachadair/taskgroup"
24
23
"github.com/goproxy/goproxy"
@@ -53,11 +52,7 @@ type Cacher struct {
53
52
54
53
// S3Client is the S3 client used to read and write cache entries to the
55
54
// 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
61
56
62
57
// KeyPrefix, if non-empty, is prepended to each key stored into S3, with an
63
58
// intervening slash.
@@ -97,7 +92,6 @@ type Cacher struct {
97
92
tasks * taskgroup.Group
98
93
start func (taskgroup.Task ) * taskgroup.Group
99
94
sema * semaphore.Weighted
100
- client * s3util.Client
101
95
102
96
pathError expvar.Int // errors constructing file paths
103
97
getRequest expvar.Int // total number of Get requests
@@ -125,7 +119,6 @@ func (c *Cacher) init() {
125
119
}
126
120
c .tasks , c .start = taskgroup .New (nil ).Limit (nt )
127
121
c .sema = semaphore .NewWeighted (int64 (nt ))
128
- c .client = & s3util.Client {Client : c .S3Client , Bucket : c .S3Bucket }
129
122
})
130
123
}
131
124
@@ -162,7 +155,7 @@ func (c *Cacher) Get(ctx context.Context, name string) (_ io.ReadCloser, oerr er
162
155
}
163
156
defer c .sema .Release (1 )
164
157
165
- obj , err := c .client .Get (ctx , c .makeKey (hash ))
158
+ obj , err := c .S3Client .Get (ctx , c .makeKey (hash ))
166
159
if errors .Is (err , fs .ErrNotExist ) {
167
160
c .getFaultMiss .Add (1 )
168
161
return nil , err
@@ -231,7 +224,7 @@ func (c *Cacher) Put(ctx context.Context, name string, data io.ReadSeeker) (oerr
231
224
sctx , cancel := context .WithTimeout (context .WithoutCancel (ctx ), 1 * time .Minute )
232
225
defer cancel ()
233
226
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 {
235
228
c .putS3Error .Add (1 )
236
229
c .logf ("[s3] put %q failed: %v" , name , err )
237
230
} else {
0 commit comments