Documentation
¶
Index ¶
- Constants
- Variables
- func FlowIDForSnapshotID(log *oplog.OpLog, snapshotID string) (int64, error)
- func Logger(ctx context.Context, task Task) *zap.Logger
- type BackupTask
- type BaseTask
- type CollectGarbageTask
- func (t *CollectGarbageTask) Cancel(withStatus v1.OperationStatus) error
- func (t *CollectGarbageTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
- func (t *CollectGarbageTask) OperationId() int64
- func (t *CollectGarbageTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
- type GenericOneoffTask
- type OneoffTask
- type PruneTask
- type ScheduledTask
- type StatsTask
- type Task
- func NewOneoffForgetSnapshotTask(repoID, planID string, flowID int64, at time.Time, snapshotID string) Task
- func NewOneoffForgetTask(repoID, planID string, flowID int64, at time.Time) Task
- func NewOneoffIndexSnapshotsTask(repoID string, at time.Time) Task
- func NewOneoffRestoreTask(repoID, planID string, flowID int64, at time.Time, ...) Task
- func NewPruneTask(repoID, planID string, force bool) Task
- func NewStatsTask(repoID, planID string, force bool) Task
- type TaskRunner
Constants ¶
View Source
const ( PlanForUnassociatedOperations = "_unassociated_" PlanForSystemTasks = "_system_" // plan for system tasks e.g. garbage collection, prune, stats, etc. TaskPriorityStats = -1 TaskPriorityDefault = 0 TaskPriorityInteractive = 1 << 1 TaskPriorityForget = 1 << 2 TaskPriorityIndexSnapshots = 1 << 3 TaskPriorityPrune = 1 << 4 )
Variables ¶
View Source
var NeverScheduledTask = ScheduledTask{}
Functions ¶
func FlowIDForSnapshotID ¶
FlowIDForSnapshotID returns the flow ID associated with the backup task that created snapshot ID or 0 if not found.
Types ¶
type BackupTask ¶
type BackupTask struct {
BaseTask
// contains filtered or unexported fields
}
BackupTask is a scheduled backup operation.
func NewOneoffBackupTask ¶
func NewOneoffBackupTask(plan *v1.Plan, at time.Time) *BackupTask
func NewScheduledBackupTask ¶
func NewScheduledBackupTask(plan *v1.Plan) (*BackupTask, error)
func (*BackupTask) Next ¶
func (t *BackupTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
func (*BackupTask) Run ¶
func (t *BackupTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type CollectGarbageTask ¶
type CollectGarbageTask struct {
BaseTask
// contains filtered or unexported fields
}
func NewCollectGarbageTask ¶
func NewCollectGarbageTask() *CollectGarbageTask
func (*CollectGarbageTask) Cancel ¶
func (t *CollectGarbageTask) Cancel(withStatus v1.OperationStatus) error
func (*CollectGarbageTask) Next ¶
func (t *CollectGarbageTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
func (*CollectGarbageTask) OperationId ¶
func (t *CollectGarbageTask) OperationId() int64
func (*CollectGarbageTask) Run ¶
func (t *CollectGarbageTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type GenericOneoffTask ¶
type GenericOneoffTask struct {
BaseTask
OneoffTask
Do func(ctx context.Context, st ScheduledTask, runner TaskRunner) error
}
func (*GenericOneoffTask) Run ¶
func (g *GenericOneoffTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type OneoffTask ¶
type OneoffTask struct {
BaseTask
RunAt time.Time
FlowID int64 // the ID of the flow this task is associated with.
DidSchedule bool
ProtoOp *v1.Operation // the prototype operation for this class of task.
}
func (*OneoffTask) Next ¶
func (o *OneoffTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
type PruneTask ¶
type PruneTask struct {
BaseTask
// contains filtered or unexported fields
}
func (*PruneTask) Next ¶
func (t *PruneTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
func (*PruneTask) Run ¶
func (t *PruneTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type ScheduledTask ¶
type ScheduledTask struct {
Task Task // the task to run
RunAt time.Time // the time at which the task should be run.
Op *v1.Operation // operation associated with this execution of the task.
}
ScheduledTask is a task that is scheduled to run at a specific time.
func (ScheduledTask) Eq ¶
func (s ScheduledTask) Eq(other ScheduledTask) bool
func (ScheduledTask) Less ¶
func (s ScheduledTask) Less(other ScheduledTask) bool
type StatsTask ¶
type StatsTask struct {
BaseTask
// contains filtered or unexported fields
}
func (*StatsTask) Next ¶
func (t *StatsTask) Next(now time.Time, runner TaskRunner) (ScheduledTask, error)
func (*StatsTask) Run ¶
func (t *StatsTask) Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error
type Task ¶
type Task interface {
Name() string // human readable name for this task.
Next(now time.Time, runner TaskRunner) (ScheduledTask, error) // returns the next scheduled task.
Run(ctx context.Context, st ScheduledTask, runner TaskRunner) error // run the task.
PlanID() string // the ID of the plan this task is associated with.
RepoID() string // the ID of the repo this task is associated with.
}
Task is a task that can be scheduled to run at a specific time.
func NewOneoffForgetTask ¶
func NewOneoffRestoreTask ¶
func NewPruneTask ¶
func NewStatsTask ¶
type TaskRunner ¶
type TaskRunner interface {
// CreateOperation creates the operation in storage and sets the operation ID in the task.
CreateOperation(*v1.Operation) error
// UpdateOperation updates the operation in storage. It must be called after CreateOperation.
UpdateOperation(*v1.Operation) error
// ExecuteHooks
ExecuteHooks(events []v1.Hook_Condition, vars hook.HookVars) error
// OpLog returns the oplog for the operations.
OpLog() *oplog.OpLog
// GetRepo returns the repo with the given ID.
GetRepo(repoID string) (*v1.Repo, error)
// GetPlan returns the plan with the given ID.
GetPlan(planID string) (*v1.Plan, error)
// GetRepoOrchestrator returns the orchestrator for the repo with the given ID.
GetRepoOrchestrator(repoID string) (*repo.RepoOrchestrator, error)
// ScheduleTask schedules a task to run at a specific time.
ScheduleTask(task Task, priority int) error
// Config returns the current config.
Config() *v1.Config
}
TaskRunner is an interface for running tasks. It is used by tasks to create operations and write logs.
Click to show internal directories.
Click to hide internal directories.