Skip to content

Commit

Permalink
chore: add executor getters
Browse files Browse the repository at this point in the history
Signed-off-by: Armando Ruocco <[email protected]>
  • Loading branch information
armru committed Feb 13, 2024
1 parent e5a4c7e commit 1446a4d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions internal/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func (Implementation) Backup(
BackupName: backupInfo.BackupName,
StartedAt: startedAt.Unix(),
StoppedAt: time.Now().Unix(),
BeginWal: exec.BeginWal,
EndWal: exec.EndWal,
BeginWal: exec.MustGetBeginWal(),
EndWal: exec.MustGetEndWal(),
BeginLsn: string(backupInfo.BeginLSN),
EndLsn: string(backupInfo.EndLSN),
BackupLabelFile: backupInfo.LabelFile,
Expand Down
25 changes: 20 additions & 5 deletions internal/backup/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,31 @@ var backupModeBackoff = wait.Backoff{
type Executor struct {
backupClient webserver.BackupClient

// TODO: these should be a getter that return an error if empty
BeginWal string
EndWal string
beginWal string
endWal string

cluster *apiv1.Cluster
backup *apiv1.Backup
repository *Repository
backupClientEndpoint string
}

// MustGetBeginWal returns the beginWal value, panics if empty
func (executor *Executor) MustGetBeginWal() string {
if executor.beginWal == "" {
panic("beginWal value is empty, pleasure run take backup before trying to access this value")
}
return executor.beginWal
}

// MustGetEndWal returns the endWal value, panics if empty
func (executor *Executor) MustGetEndWal() string {
if executor.endWal == "" {
panic("endWal value is empty, pleasure run take backup before trying to access this value")
}
return executor.endWal
}

// tablespace represent a tablespace location
type tablespace struct {
// path is the path where the tablespaces data is stored
Expand Down Expand Up @@ -89,7 +104,7 @@ func (executor *Executor) setBackupMode(ctx context.Context) error {
logger := logging.FromContext(ctx)

var currentWALErr error
executor.BeginWal, currentWALErr = executor.getCurrentWALFile(ctx)
executor.beginWal, currentWALErr = executor.getCurrentWALFile(ctx)
if currentWALErr != nil {
return currentWALErr
}
Expand Down Expand Up @@ -226,7 +241,7 @@ func (executor *Executor) unsetBackupMode(ctx context.Context) (*webserver.Backu
logger.Info("PostgreSQL Backup mode stopped")

var err error
executor.EndWal, err = executor.getCurrentWALFile(ctx)
executor.endWal, err = executor.getCurrentWALFile(ctx)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 1446a4d

Please sign in to comment.