@@ -95,7 +95,7 @@ func (s *S3Cache) init() {
95
95
}
96
96
97
97
// Get implements the corresponding callback of the cache protocol.
98
- func (s * S3Cache ) Get (ctx context.Context , actionID string ) (objectID , diskPath string , _ error ) {
98
+ func (s * S3Cache ) Get (ctx context.Context , actionID string ) (outputID , diskPath string , _ error ) {
99
99
s .init ()
100
100
101
101
objID , diskPath , err := s .Local .Get (ctx , actionID )
@@ -116,29 +116,29 @@ func (s *S3Cache) Get(ctx context.Context, actionID string) (objectID, diskPath
116
116
}
117
117
118
118
// We got an action hit remotely, try to update the local copy.
119
- objectID , mtime , err := parseAction (action )
119
+ outputID , mtime , err := parseAction (action )
120
120
if err != nil {
121
121
return "" , "" , err
122
122
}
123
123
124
- object , err := s .S3Client .GetData (ctx , s .objectKey ( objectID ))
124
+ object , err := s .S3Client .GetData (ctx , s .outputKey ( outputID ))
125
125
if err != nil {
126
126
// At this point we know the action exists, so if we can't read the
127
127
// object report it as an error rather than a cache miss.
128
- return "" , "" , fmt .Errorf ("[s3] read object %s: %w" , objectID , err )
128
+ return "" , "" , fmt .Errorf ("[s3] read object %s: %w" , outputID , err )
129
129
}
130
130
s .getFaultHit .Add (1 )
131
131
132
132
// Now we should have the body; poke it into the local cache. Preserve the
133
133
// modification timestamp recorded with the original action.
134
134
diskPath , err = s .Local .Put (ctx , gocache.Object {
135
135
ActionID : actionID ,
136
- ObjectID : objectID ,
136
+ OutputID : outputID ,
137
137
Size : int64 (len (object )),
138
138
Body : bytes .NewReader (object ),
139
139
ModTime : mtime ,
140
140
})
141
- return objectID , diskPath , err
141
+ return outputID , diskPath , err
142
142
}
143
143
144
144
// Put implements the corresponding callback of the cache protocol.
@@ -168,14 +168,14 @@ func (s *S3Cache) Put(ctx context.Context, obj gocache.Object) (diskPath string,
168
168
169
169
// Stage 1: Maybe write the object. Do this before writing the action
170
170
// record so we are less likely to get a spurious miss later.
171
- mtime , err := s .maybePutObject (sctx , obj .ObjectID , diskPath , etr .ETag ())
171
+ mtime , err := s .maybePutObject (sctx , obj .OutputID , diskPath , etr .ETag ())
172
172
if err != nil {
173
173
return err
174
174
}
175
175
176
176
// Stage 2: Write the action record.
177
177
if err := s .S3Client .Put (ctx , s .actionKey (obj .ActionID ),
178
- strings .NewReader (fmt .Sprintf ("%s %d" , obj .ObjectID , mtime .UnixNano ()))); err != nil {
178
+ strings .NewReader (fmt .Sprintf ("%s %d" , obj .OutputID , mtime .UnixNano ()))); err != nil {
179
179
gocache .Logf (ctx , "write action %s: %v" , obj .ActionID , err )
180
180
return err
181
181
}
@@ -212,10 +212,10 @@ func (s *S3Cache) SetMetrics(_ context.Context, m *expvar.Map) {
212
212
// maybePutObject writes the specified object contents to S3 if there is not
213
213
// already a matching key with the same etag. It returns the modified time of
214
214
// the object file, whether or not it was sent to S3.
215
- func (s * S3Cache ) maybePutObject (ctx context.Context , objectID , diskPath , etag string ) (time.Time , error ) {
215
+ func (s * S3Cache ) maybePutObject (ctx context.Context , outputID , diskPath , etag string ) (time.Time , error ) {
216
216
f , err := os .Open (diskPath )
217
217
if err != nil {
218
- gocache .Logf (ctx , "[s3] open local object %s: %v" , objectID , err )
218
+ gocache .Logf (ctx , "[s3] open local object %s: %v" , outputID , err )
219
219
return time.Time {}, err
220
220
}
221
221
defer f .Close ()
@@ -224,10 +224,10 @@ func (s *S3Cache) maybePutObject(ctx context.Context, objectID, diskPath, etag s
224
224
return time.Time {}, err
225
225
}
226
226
227
- written , err := s .S3Client .PutCond (ctx , s .objectKey ( objectID ), etag , f )
227
+ written , err := s .S3Client .PutCond (ctx , s .outputKey ( outputID ), etag , f )
228
228
if err != nil {
229
229
s .putS3Error .Add (1 )
230
- gocache .Logf (ctx , "[s3] put object %s: %v" , objectID , err )
230
+ gocache .Logf (ctx , "[s3] put object %s: %v" , outputID , err )
231
231
return fi .ModTime (), err
232
232
}
233
233
if written {
@@ -245,7 +245,7 @@ func (s *S3Cache) makeKey(parts ...string) string {
245
245
}
246
246
247
247
func (s * S3Cache ) actionKey (id string ) string { return s .makeKey ("action" , id [:2 ], id ) }
248
- func (s * S3Cache ) objectKey (id string ) string { return s .makeKey ("object " , id [:2 ], id ) }
248
+ func (s * S3Cache ) outputKey (id string ) string { return s .makeKey ("output " , id [:2 ], id ) }
249
249
250
250
func (s * S3Cache ) uploadConcurrency () int {
251
251
if s .UploadConcurrency <= 0 {
@@ -254,7 +254,7 @@ func (s *S3Cache) uploadConcurrency() int {
254
254
return s .UploadConcurrency
255
255
}
256
256
257
- func parseAction (data []byte ) (objectID string , mtime time.Time , _ error ) {
257
+ func parseAction (data []byte ) (outputID string , mtime time.Time , _ error ) {
258
258
fs := strings .Fields (string (data ))
259
259
if len (fs ) != 2 {
260
260
return "" , time.Time {}, errors .New ("invalid action record" )
0 commit comments