feat: add configuration parsing and job definitions

Add a YAML config schema for migration jobs (source/target schema, table, primary key, options) and parse it at startup.
This commit is contained in:
2026-04-10 14:00:00 -05:00
parent 4f181269a4
commit 1f8689cdfc
16 changed files with 1226 additions and 30 deletions

View File

@@ -0,0 +1,47 @@
package main
import (
"context"
"fmt"
log "github.com/sirupsen/logrus"
)
type JobError struct {
ShouldCancelJob bool
Msg string
Prev error
}
func (e *JobError) Error() string {
if e.Prev != nil {
return fmt.Sprintf("%s: %v", e.Msg, e.Prev)
}
return e.Msg
}
func jobErrorHandler(ctx context.Context, chErrorsIn <-chan JobError) error {
for {
if ctx.Err() != nil {
return nil
}
select {
case <-ctx.Done():
return nil
case err, ok := <-chErrorsIn:
if !ok {
return nil
}
if err.ShouldCancelJob {
log.Error(err.Msg, " - ", err.Prev)
return &err
}
log.Error(err.Msg, " - ", err.Prev)
}
}
}