Skip to content

Commit 0265a1d

Browse files
committed
pipeline: cache uploadable files prior to remote write
1 parent ba91e53 commit 0265a1d

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

internal/pipeline/merging.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,7 @@ func (m *filesystemMerging) WithEachMerged(ctx context.Context, f func(context.C
287287
}
288288
logger.Logf("found %T agent", agent)
289289

290-
// Write each file to our remote agent
291-
var merged []mergedFile
292-
successfulRemoteWrites := 0
290+
// Write each file to local cache
293291
for i := range files {
294292
// Optionally Flatten Batches
295293
if m.shard.Mergable.FlattenBatches != nil {
@@ -307,9 +305,14 @@ func (m *filesystemMerging) WithEachMerged(ctx context.Context, f func(context.C
307305
el.Add(err)
308306
continue
309307
}
308+
}
310309

311-
// Upload the file
312-
if filename, err := f(ctx, i, agent, files[i]); err != nil {
310+
// Write each file to the remote agent
311+
var merged []mergedFile
312+
successfulRemoteWrites := 0
313+
for i := range files {
314+
filename, err := f(ctx, i, agent, files[i]) // upload
315+
if err != nil {
313316
err = fmt.Errorf("problem from callback: %v", err)
314317
span.RecordError(err)
315318
el.Add(err)
@@ -326,7 +329,6 @@ func (m *filesystemMerging) WithEachMerged(ctx context.Context, f func(context.C
326329
}
327330
}
328331
}
329-
330332
logger.Logf("wrote %d of %d files to remote agent", successfulRemoteWrites, len(files))
331333

332334
span.SetAttributes(

0 commit comments

Comments
 (0)