refactor: rename Batch to Partition in error handling and processing functions for consistency

This commit is contained in:
2026-04-11 00:30:54 -05:00
parent 9eb9821daf
commit 955bc65ce9
10 changed files with 151 additions and 151 deletions

View File

@@ -10,7 +10,7 @@ import (
)
type ExtractorError struct {
Batch models.Partition
Partition models.Partition
LastId int64
HasLastId bool
Msg string
@@ -24,9 +24,9 @@ func ExtractorErrorHandler(
ctx context.Context,
maxRetryAttempts int,
chErrorsIn <-chan ExtractorError,
chBatchesOut chan<- models.Partition,
chPartitionsOut chan<- models.Partition,
chJobErrorsOut chan<- JobError,
wgActiveBatches *sync.WaitGroup,
wgActivePartitions *sync.WaitGroup,
) {
for {
if ctx.Err() != nil {
@@ -42,10 +42,10 @@ func ExtractorErrorHandler(
return
}
if err.Batch.RetryCounter >= maxRetryAttempts {
if err.Partition.RetryCounter >= maxRetryAttempts {
jobError := JobError{
ShouldCancelJob: false,
Msg: fmt.Sprintf("batch %v reached max retries (%d)", err.Batch.Id, maxRetryAttempts),
Msg: fmt.Sprintf("Partition %v reached max retries (%d)", err.Partition.Id, maxRetryAttempts),
Prev: &err,
}
@@ -55,22 +55,22 @@ func ExtractorErrorHandler(
return
}
wgActiveBatches.Done()
wgActivePartitions.Done()
continue
}
newBatch := err.Batch
newBatch.RetryCounter++
newPartition := err.Partition
newPartition.RetryCounter++
if err.HasLastId {
newBatch.ParentId = err.Batch.Id
newBatch.Id = uuid.New()
newBatch.LowerLimit = err.LastId
newBatch.IsLowerLimitInclusive = false
newPartition.ParentId = err.Partition.Id
newPartition.Id = uuid.New()
newPartition.LowerLimit = err.LastId
newPartition.IsLowerLimitInclusive = false
}
select {
case chBatchesOut <- newBatch:
case chPartitionsOut <- newPartition:
case <-ctx.Done():
return
}

View File

@@ -21,9 +21,9 @@ func LoaderErrorHandler(
ctx context.Context,
maxRetryAttempts int,
chErrorsIn <-chan LoaderError,
chChunksOut chan<- models.Batch,
chBatchesOut chan<- models.Batch,
chJobErrorsOut chan<- JobError,
wgActiveChunks *sync.WaitGroup,
wgActiveBatches *sync.WaitGroup,
) {
for {
if ctx.Err() != nil {
@@ -42,7 +42,7 @@ func LoaderErrorHandler(
if err.RetryCounter >= maxRetryAttempts {
jobError := JobError{
ShouldCancelJob: false,
Msg: fmt.Sprintf("chunk %v reached max retries (%d)", err.Id, maxRetryAttempts),
Msg: fmt.Sprintf("Batch %v reached max retries (%d)", err.Id, maxRetryAttempts),
Prev: &err,
}
@@ -52,14 +52,14 @@ func LoaderErrorHandler(
return
}
wgActiveChunks.Done()
wgActiveBatches.Done()
continue
}
err.RetryCounter++
select {
case chChunksOut <- err.Batch:
case chBatchesOut <- err.Batch:
case <-ctx.Done():
return
}