Documentation ¶
Overview ¶
Package mock contains mock implementations of different task interfaces.
Index ¶
- type Executor
- func (e *Executor) Cancel(context.Context, influxdb.ID) error
- func (e *Executor) Execute(ctx context.Context, id scheduler.ID, scheduledAt time.Time, runAt time.Time) error
- func (e *Executor) FailNextCallToExecute(err error)
- func (e *Executor) ManualRun(ctx context.Context, id influxdb.ID, runID influxdb.ID) (executor.Promise, error)
- func (e *Executor) Wait()
- type TaskControlService
- func (d *TaskControlService) AddRunLog(ctx context.Context, taskID, runID influxdb.ID, when time.Time, log string) error
- func (t *TaskControlService) CreateRun(_ context.Context, taskID influxdb.ID, scheduledFor time.Time, runAt time.Time) (*influxdb.Run, error)
- func (d *TaskControlService) CreatedFor(taskID influxdb.ID) []*influxdb.Run
- func (t *TaskControlService) CurrentlyRunning(ctx context.Context, taskID influxdb.ID) ([]*influxdb.Run, error)
- func (d *TaskControlService) FinishRun(_ context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error)
- func (d *TaskControlService) FinishedRun(runID influxdb.ID) *influxdb.Run
- func (d *TaskControlService) FinishedRuns() []*influxdb.Run
- func (t *TaskControlService) ManualRuns(ctx context.Context, taskID influxdb.ID) ([]*influxdb.Run, error)
- func (d *TaskControlService) PollForNumberCreated(taskID influxdb.ID, count int) ([]*influxdb.Run, error)
- func (d *TaskControlService) SetManualRuns(runs []*influxdb.Run)
- func (d *TaskControlService) SetTask(task *influxdb.Task)
- func (t *TaskControlService) StartManualRun(_ context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error)
- func (d *TaskControlService) TotalRunsCreatedForTask(taskID influxdb.ID) int
- func (d *TaskControlService) UpdateRunState(ctx context.Context, taskID, runID influxdb.ID, when time.Time, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
func NewExecutor ¶
func NewExecutor() *Executor
func (*Executor) FailNextCallToExecute ¶
FailNextCallToExecute causes the next call to e.Execute to unconditionally return err.
type TaskControlService ¶
type TaskControlService struct {
// contains filtered or unexported fields
}
TaskControlService is a mock implementation of TaskControlService (used by NewScheduler).
func NewTaskControlService ¶
func NewTaskControlService() *TaskControlService
func (*TaskControlService) AddRunLog ¶
func (d *TaskControlService) AddRunLog(ctx context.Context, taskID, runID influxdb.ID, when time.Time, log string) error
AddRunLog adds a log line to the run.
func (*TaskControlService) CreatedFor ¶
func (d *TaskControlService) CreatedFor(taskID influxdb.ID) []*influxdb.Run
func (*TaskControlService) CurrentlyRunning ¶
func (t *TaskControlService) CurrentlyRunning(ctx context.Context, taskID influxdb.ID) ([]*influxdb.Run, error)
func (*TaskControlService) FinishRun ¶
func (d *TaskControlService) FinishRun(_ context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error)
func (*TaskControlService) FinishedRun ¶
func (d *TaskControlService) FinishedRun(runID influxdb.ID) *influxdb.Run
func (*TaskControlService) FinishedRuns ¶
func (d *TaskControlService) FinishedRuns() []*influxdb.Run
func (*TaskControlService) ManualRuns ¶
func (t *TaskControlService) ManualRuns(ctx context.Context, taskID influxdb.ID) ([]*influxdb.Run, error)
func (*TaskControlService) PollForNumberCreated ¶
func (d *TaskControlService) PollForNumberCreated(taskID influxdb.ID, count int) ([]*influxdb.Run, error)
PollForNumberCreated blocks for a small amount of time waiting for exactly the given count of created and unfinished runs for the given task ID. If the expected number isn't found in time, it returns an error.
Because the scheduler and executor do a lot of state changes asynchronously, this is useful in test.
func (*TaskControlService) SetManualRuns ¶
func (d *TaskControlService) SetManualRuns(runs []*influxdb.Run)
func (*TaskControlService) SetTask ¶
func (d *TaskControlService) SetTask(task *influxdb.Task)
SetTask sets the task. SetTask must be called before CreateNextRun, for a given task ID.
func (*TaskControlService) StartManualRun ¶
func (t *TaskControlService) StartManualRun(_ context.Context, taskID, runID influxdb.ID) (*influxdb.Run, error)
func (*TaskControlService) TotalRunsCreatedForTask ¶
func (d *TaskControlService) TotalRunsCreatedForTask(taskID influxdb.ID) int
TotalRunsCreatedForTask returns the number of runs created for taskID.
func (*TaskControlService) UpdateRunState ¶
func (d *TaskControlService) UpdateRunState(ctx context.Context, taskID, runID influxdb.ID, when time.Time, state influxdb.RunStatus) error
UpdateRunState sets the run state at the respective time.