diff --git a/cmd/backup/main.go b/cmd/backup/main.go index 3ce06e3b..60cec2c5 100644 --- a/cmd/backup/main.go +++ b/cmd/backup/main.go @@ -73,7 +73,7 @@ func startService(configFile string, remote bool) error { return fmt.Errorf("failed to load configuration: %w", err) } - appLogger := setDefaultLoggers(ctx, config) + appLogger := setDefaultLoggers(ctx, config.ServiceConfig.GetLoggerOrDefault()) slog.Info("Aerospike Backup Service", "commit", commit, "buildTime", buildTime) // schedule all configured backups @@ -121,9 +121,9 @@ func startService(configFile string, remote bool) error { return err } -func setDefaultLoggers(ctx context.Context, config *model.Config) *slog.Logger { +func setDefaultLoggers(ctx context.Context, loggerConfig *model.LoggerConfig) *slog.Logger { appLogger := slog.New( - util.LogHandler(config.ServiceConfig.GetLoggerOrDefault()), + util.LogHandler(loggerConfig), ) slog.SetDefault(appLogger) logger.SetDefault(util.NewQuartzLogger(ctx)) diff --git a/pkg/service/backup_routine_handler.go b/pkg/service/backup_routine_handler.go index fc27d168..73f606a9 100644 --- a/pkg/service/backup_routine_handler.go +++ b/pkg/service/backup_routine_handler.go @@ -97,28 +97,27 @@ type BackupHandlerHolder map[string]backupRunner // newBackupRoutineHandler returns a new BackupRoutineHandler instance. func newBackupRoutineHandler( - config *model.Config, clientManager aerospike.ClientManager, backupService Backup, routineName string, + routine *model.BackupRoutine, backupBackend *BackupBackend, lastRun *model.LastBackupRun, ) *BackupRoutineHandler { - backupRoutine := config.BackupRoutines[routineName] - backupPolicy := backupRoutine.BackupPolicy - backupStorage := backupRoutine.Storage + backupPolicy := routine.BackupPolicy + backupStorage := routine.Storage logger := slog.Default().With(slog.String("routine", routineName)) return &BackupRoutineHandler{ backupService: backupService, metadataWriter: backupBackend, - backupRoutine: backupRoutine, + backupRoutine: routine, backupFullPolicy: backupPolicy, backupIncrPolicy: backupPolicy.CopySMDDisabled(), // incremental backups should not contain metadata routineName: routineName, - namespaces: backupRoutine.Namespaces, + namespaces: routine.Namespaces, storage: backupStorage, - secretAgent: backupRoutine.SecretAgent, + secretAgent: routine.SecretAgent, lastRun: lastRun, retry: newRetryExecutor( backupPolicy.GetRetryPolicyOrDefault(), diff --git a/pkg/service/config_applier.go b/pkg/service/config_applier.go index 032cb296..882bca76 100644 --- a/pkg/service/config_applier.go +++ b/pkg/service/config_applier.go @@ -96,11 +96,11 @@ func makeHandlers( var wg sync.WaitGroup var mu sync.Mutex - for routineName := range config.BackupRoutines { + for routineName, routine := range config.BackupRoutines { wg.Add(1) go func() { defer wg.Done() - handler := makeHandler(ctx, clientManager, config, backends, oldHandlers, routineName) + handler := makeHandler(ctx, clientManager, backends, oldHandlers, routineName, routine) mu.Lock() handlers[routineName] = handler mu.Unlock() @@ -114,10 +114,10 @@ func makeHandlers( func makeHandler( ctx context.Context, clientManager aerospike.ClientManager, - config *model.Config, backends BackendsHolder, oldHandlers BackupHandlerHolder, routineName string, + routine *model.BackupRoutine, ) *BackupRoutineHandler { backupService := NewBackupGo() backend, _ := backends.Get(routineName) @@ -130,5 +130,5 @@ func makeHandler( lastRun = backend.findLastRun(ctx) // this scan can take some time. } - return newBackupRoutineHandler(config, clientManager, backupService, routineName, backend, lastRun) + return newBackupRoutineHandler(clientManager, backupService, routineName, routine, backend, lastRun) }