Skip to content

Commit

Permalink
fixup! feat(batch): Add batching for SQL jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
mgaffney committed Oct 24, 2024
1 parent dd51da7 commit 06e8d53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions internal/scheduler/batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,13 @@ func New(ctx context.Context, c *Config) (*Batch, error) {
}

// Status reports the job’s current status.
func (d *Batch) Status() scheduler.JobStatus {
d.mu.Lock()
defer d.mu.Unlock()
func (b *Batch) Status() scheduler.JobStatus {
b.mu.Lock()
defer b.mu.Unlock()
return scheduler.JobStatus{
Completed: d.totalCompleted,
Total: d.c.TotalToComplete,
Retries: d.retries,
Completed: b.totalCompleted,
Total: b.c.TotalToComplete,
Retries: b.retries,
}
}

Expand Down
7 changes: 5 additions & 2 deletions internal/scheduler/batch/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ func (tr *testRunner) Exec(ctx context.Context, batchSize int) (int, error) {
}
run := tr.runs[tr.call]
rec := run.recorder(tr.conf)
rec.Exec(ctx, batchSize)
if _, err := rec.Exec(ctx, batchSize); err != nil {
return 0, err
}
tr.call++
return run.ret(ctx, batchSize, tr.conf)
}
Expand Down Expand Up @@ -559,5 +561,6 @@ func TestBatch_batchCompleted(t *testing.T) {
require.NoError(err)
assert.NotNil(b)

b.adjustBatchSize(ctx, 10)
err = b.adjustBatchSize(ctx, 10)
require.NoError(err)
}

0 comments on commit 06e8d53

Please sign in to comment.