Skip to content

Commit

Permalink
refactor: using string and unified format for time
Browse files Browse the repository at this point in the history
Signed-off-by: mlycore <[email protected]>
  • Loading branch information
mlycore committed Nov 15, 2023
1 parent ee268a2 commit 1023ca7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions pitr/cli/internal/cmd/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/apache/shardingsphere-on-cloud/pitr/cli/internal/pkg/xerr"
"github.com/apache/shardingsphere-on-cloud/pitr/cli/pkg/logging"
"github.com/apache/shardingsphere-on-cloud/pitr/cli/pkg/prettyoutput"
"github.com/apache/shardingsphere-on-cloud/pitr/cli/pkg/timeutil"

"github.com/google/uuid"
"github.com/jedib0t/go-pretty/v6/progress"
Expand Down Expand Up @@ -225,8 +226,8 @@ func exportData(proxy pkg.IShardingSphereProxy, ls pkg.ILocalStorage) (lsBackup
Info: &model.BackupMetaInfo{
ID: uuid.New().String(), // generate uuid for this backup
CSN: csn,
StartTime: time.Now().Unix(),
EndTime: 0,
StartTime: timeutil.Now(),
EndTime: timeutil.Init(),
BackupMode: BackupMode,
},
SsBackup: &model.SsBackup{
Expand Down Expand Up @@ -299,8 +300,8 @@ func _execBackup(as pkg.IAgentServer, node *model.StorageNode, dnCh chan *model.
Port: node.Port,
Status: model.SsBackupStatusRunning,
BackupID: backupID,
StartTime: time.Now().Unix(),
EndTime: 0,
StartTime: timeutil.Now(),
EndTime: timeutil.Init(),
}
dnCh <- dn
return nil
Expand Down Expand Up @@ -363,7 +364,7 @@ func checkBackupStatus(lsBackup *model.LsBackup) model.BackupStatus {

lsBackup.DnList = dnResult
lsBackup.SsBackup.Status = backupFinalStatus
lsBackup.Info.EndTime = time.Now().Unix()
lsBackup.Info.EndTime = timeutil.Now()
return backupFinalStatus
}

Expand All @@ -388,14 +389,14 @@ func checkStatus(as pkg.IAgentServer, sn *model.StorageNode, dn *model.DataNode,
if err != nil {
tracker.MarkAsErrored()
dn.Status = status
dn.EndTime = time.Now().Unix()
dn.EndTime = timeutil.Now()
dnCh <- dn
done <- struct{}{}
}
if status == model.SsBackupStatusCompleted || status == model.SsBackupStatusFailed {
tracker.MarkAsDone()
dn.Status = status
dn.EndTime = time.Now().Unix()
dn.EndTime = timeutil.Now()
dnCh <- dn
done <- struct{}{}
}
Expand Down
8 changes: 4 additions & 4 deletions pitr/cli/internal/pkg/model/ls_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ type (
ID string `json:"id"`
CSN string `json:"csn"`
BackupMode DBBackupMode `json:"backup_mode"`
StartTime int64 `json:"start_time"` // Unix time
EndTime int64 `json:"end_time"` // Unix time
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
FileName string
}

Expand All @@ -39,8 +39,8 @@ type (
Port uint16 `json:"port"`
Status BackupStatus `json:"status"`
BackupID string `json:"backup_id"`
StartTime int64 `json:"start_time"` // Unix time
EndTime int64 `json:"end_time"` // Unix time
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
}
)

Expand Down

0 comments on commit 1023ca7

Please sign in to comment.