2023-12-27 22:59:20 +08:00
|
|
|
package entity
|
|
|
|
|
|
|
|
|
|
import (
|
2024-01-11 11:35:51 +08:00
|
|
|
"context"
|
|
|
|
|
"mayfly-go/pkg/runner"
|
2024-01-05 08:55:34 +08:00
|
|
|
"mayfly-go/pkg/utils/timex"
|
2023-12-27 22:59:20 +08:00
|
|
|
)
|
|
|
|
|
|
2024-01-11 11:35:51 +08:00
|
|
|
var _ DbJob = (*DbRestore)(nil)
|
2023-12-27 22:59:20 +08:00
|
|
|
|
|
|
|
|
// DbRestore 数据库恢复任务
|
|
|
|
|
type DbRestore struct {
|
2024-01-11 11:35:51 +08:00
|
|
|
*DbJobBaseImpl
|
2024-01-05 08:55:34 +08:00
|
|
|
|
|
|
|
|
PointInTime timex.NullTime `json:"pointInTime"` // 指定数据库恢复的时间点
|
|
|
|
|
DbBackupId uint64 `json:"dbBackupId"` // 用于恢复的数据库恢复任务ID
|
|
|
|
|
DbBackupHistoryId uint64 `json:"dbBackupHistoryId"` // 用于恢复的数据库恢复历史ID
|
|
|
|
|
DbBackupHistoryName string `json:"dbBackupHistoryName"` // 数据库恢复历史名称
|
2023-12-27 22:59:20 +08:00
|
|
|
}
|
|
|
|
|
|
2024-01-11 11:35:51 +08:00
|
|
|
func (d *DbRestore) SetRun(fn func(ctx context.Context, job DbJob)) {
|
|
|
|
|
d.run = func(ctx context.Context) {
|
|
|
|
|
fn(ctx, d)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *DbRestore) SetRunnable(fn func(job DbJob, next runner.NextFunc) bool) {
|
|
|
|
|
d.runnable = func(next runner.NextFunc) bool {
|
|
|
|
|
return fn(d, next)
|
2023-12-27 22:59:20 +08:00
|
|
|
}
|
|
|
|
|
}
|