feat: add context support to migration job processing for improved cancellation and error handling
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -37,6 +38,10 @@ const (
|
||||
func main() {
|
||||
configureLog()
|
||||
startTime := time.Now()
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
log.Info("=== Starting migration ===")
|
||||
log.Infof("Number of loaders: %d, Chunk size: %d", NumLoaders, ChunkSize)
|
||||
|
||||
@@ -50,7 +55,7 @@ func main() {
|
||||
|
||||
for _, job := range migrationJobs {
|
||||
log.Infof(">>> Processing job: %s.%s <<<", job.Schema, job.Table)
|
||||
processMigrationJob(sourceDb, targetDb, job)
|
||||
processMigrationJob(ctx, sourceDb, targetDb, job)
|
||||
}
|
||||
|
||||
totalDuration := time.Since(startTime)
|
||||
|
||||
Reference in New Issue
Block a user