feat: add context support to error handlers for improved cancellation and error management

This commit is contained in:
2026-04-08 23:07:41 -05:00
parent d3a3b26bb3
commit 0ee5d9032c
3 changed files with 76 additions and 32 deletions

View File

@@ -36,8 +36,10 @@ func processMigrationJob(sourceDb *sql.DB, targetDb *pgxpool.Pool, job Migration
defer close(chJobErrors)
go func() {
if err := jobErrorHandler(chJobErrors); err != nil {
cancel()
if err := jobErrorHandler(ctx, chJobErrors); err != nil {
if ctx.Err() == nil {
cancel()
}
}
}()
@@ -45,7 +47,7 @@ func processMigrationJob(sourceDb *sql.DB, targetDb *pgxpool.Pool, job Migration
chExtractorErrors := make(chan ExtractorError, len(batches))
go func() {
extractorErrorHandler(chExtractorErrors, chBatches, chJobErrors)
extractorErrorHandler(ctx, chExtractorErrors, chBatches, chJobErrors)
}()
chChunks := make(chan Chunk, QueueSize)