feat: refactor models to improve type handling and enhance error management across migration processes

This commit is contained in:
2026-04-10 19:27:27 -05:00
parent c2ea84bfcf
commit ca621352c9
7 changed files with 121 additions and 44 deletions

View File

@@ -4,10 +4,13 @@ import (
"context"
"fmt"
"sync"
"git.ksdemosapps.com/kylesoda/go-migrate/internal/app/custom_errors"
"git.ksdemosapps.com/kylesoda/go-migrate/internal/app/models"
)
type LoaderError struct {
Chunk
models.Chunk
Msg string
}
@@ -18,8 +21,8 @@ func (e *LoaderError) Error() string {
func loaderErrorHandler(
ctx context.Context,
chErrorsIn <-chan LoaderError,
chChunksOut chan<- Chunk,
chJobErrorsOut chan<- JobError,
chChunksOut chan<- models.Chunk,
chJobErrorsOut chan<- custom_errors.JobError,
wgActiveChunks *sync.WaitGroup,
) {
for {
@@ -37,7 +40,7 @@ func loaderErrorHandler(
}
if err.RetryCounter >= maxRetryAttempts {
jobError := JobError{
jobError := custom_errors.JobError{
ShouldCancelJob: false,
Msg: fmt.Sprintf("chunk %v reached max retries (%d)", err.Id, maxRetryAttempts),
Prev: &err,