Skip to content

Commit

Permalink
change where target connect happens (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickDubelman authored Jun 18, 2024
1 parent 378a93f commit 78f6e4c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ func (job JobConfig) syncTargets() (string, []SyncResult, error) {
primaryKeyIndices: primaryKeyIndices,
columns: job.Columns,
}

// Connect to each target
if err := targets[i].connect(); err != nil {
return "", nil, err
}
}

// Get all rows from the source table and put them in a map by their primary key
Expand All @@ -70,6 +65,15 @@ func (job JobConfig) syncTargets() (string, []SyncResult, error) {
go func(target table) {
defer wg.Done()

// Connect to each target
if err := target.connect(); err != nil {
resultChan <- SyncResult{
Target: target.config,
Error: err,
}
return
}

checksum, synced, err := target.syncTarget(sourceChecksum, sourceMap)
target.Close() // Close the target's connection pool

Expand Down

0 comments on commit 78f6e4c

Please sign in to comment.