Documentation
¶
Overview ¶
Package mock contains mock implementations of different task interfaces.
Index ¶
- type DesiredState
- func (d *DesiredState) CreateNextRun(_ context.Context, taskID platform.ID, now int64) (backend.RunCreation, error)
- func (d *DesiredState) CreatedFor(taskID platform.ID) []backend.QueuedRun
- func (d *DesiredState) FinishRun(_ context.Context, taskID, runID platform.ID) error
- func (d *DesiredState) PollForNumberCreated(taskID platform.ID, count int) ([]scheduler.QueuedRun, error)
- func (d *DesiredState) SetTaskMeta(taskID platform.ID, meta backend.StoreTaskMeta)
- type Executor
- type RunPromise
- type RunResult
- type Scheduler
- func (s *Scheduler) ClaimError(err error)
- func (s *Scheduler) ClaimTask(task *backend.StoreTask, meta *backend.StoreTaskMeta) error
- func (s *Scheduler) ReleaseError(err error)
- func (s *Scheduler) ReleaseTask(taskID platform.ID) error
- func (s *Scheduler) TaskCreateChan() <-chan *Task
- func (s *Scheduler) TaskFor(id platform.ID) *Task
- func (s *Scheduler) TaskReleaseChan() <-chan *Task
- func (s *Scheduler) Tick(now int64)
- func (s *Scheduler) WithLogger(l *zap.Logger)
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DesiredState ¶
type DesiredState struct {
// contains filtered or unexported fields
}
DesiredState is a mock implementation of DesiredState (used by NewScheduler).
func NewDesiredState ¶
func NewDesiredState() *DesiredState
func (*DesiredState) CreateNextRun ¶
func (d *DesiredState) CreateNextRun(_ context.Context, taskID platform.ID, now int64) (backend.RunCreation, error)
CreateNextRun creates the next run for the given task. Refer to the documentation for SetTaskPeriod to understand how the times are determined.
func (*DesiredState) CreatedFor ¶
func (d *DesiredState) CreatedFor(taskID platform.ID) []backend.QueuedRun
func (*DesiredState) FinishRun ¶
func (d *DesiredState) FinishRun(_ context.Context, taskID, runID platform.ID) error
func (*DesiredState) PollForNumberCreated ¶
func (d *DesiredState) PollForNumberCreated(taskID platform.ID, count int) ([]scheduler.QueuedRun, error)
PollForNumberCreated blocks for a small amount of time waiting for exactly the given count of created 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 (*DesiredState) SetTaskMeta ¶
func (d *DesiredState) SetTaskMeta(taskID platform.ID, meta backend.StoreTaskMeta)
SetTaskMeta sets the task meta for the given task ID. SetTaskMeta must be called before CreateNextRun, for a given task ID.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
func NewExecutor ¶
func NewExecutor() *Executor
func (*Executor) PollForNumberRunning ¶
func (e *Executor) PollForNumberRunning(taskID platform.ID, count int) ([]*RunPromise, error)
PollForNumberRunning blocks for a small amount of time waiting for exactly the given count of active 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 (*Executor) RunningFor ¶
func (e *Executor) RunningFor(taskID platform.ID) []*RunPromise
RunningFor returns the run promises for the given task.
func (*Executor) WithLogger ¶
type RunPromise ¶
type RunPromise struct {
// contains filtered or unexported fields
}
RunPromise is a mock RunPromise.
func NewRunPromise ¶
func NewRunPromise(qr backend.QueuedRun) *RunPromise
func (*RunPromise) Cancel ¶
func (p *RunPromise) Cancel()
func (*RunPromise) Finish ¶
func (p *RunPromise) Finish(r backend.RunResult, err error)
Finish unblocks any call to Wait, to return r and err. Only the first call to Finish has any effect.
func (*RunPromise) Run ¶
func (p *RunPromise) Run() backend.QueuedRun
type RunResult ¶
type RunResult struct {
// contains filtered or unexported fields
}
RunResult is a mock implementation of RunResult.
func NewRunResult ¶
func (*RunResult) IsRetryable ¶
type Scheduler ¶
Scheduler is a mock implementation of a task scheduler.
func NewScheduler ¶
func NewScheduler() *Scheduler
func (*Scheduler) ClaimError ¶
ClaimError sets an error to be returned by s.ClaimTask, if err is not nil.
func (*Scheduler) ReleaseError ¶
ReleaseError sets an error to be returned by s.ReleaseTask, if err is not nil.