task

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package task is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BreakableResult

type BreakableResult interface {
	WithMessage
	// Break will stop task execution
	Break() WithMessage
}

BreakableResult defines a result which can stop task execution

func Complete

func Complete() BreakableResult

Complete means complete the current task and run the next one

func Retry

func Retry(dur time.Duration) BreakableResult

Retry means continue all next tasks and retry after dur

type Context

type Context[T any] interface {
	context.Context
	Self() *T
}

Context is a wrapper of any struct which can return its self It's defined to avoid calling ctx.Value()

type ContinuableResult

type ContinuableResult interface {
	WithMessage
	// Continue ignores errs of the current task and will continue task execution
	Continue() WithMessage
}

ContinuableResult defines a result which can continue task execution

func Fail

func Fail() ContinuableResult

Fail means fail the current task and skip all next tasks

type MockBreakableResult

type MockBreakableResult struct {
	// contains filtered or unexported fields
}

MockBreakableResult is a mock of BreakableResult interface.

func NewMockBreakableResult

func NewMockBreakableResult(ctrl *gomock.Controller) *MockBreakableResult

NewMockBreakableResult creates a new mock instance.

func (*MockBreakableResult) Break

func (m *MockBreakableResult) Break() WithMessage

Break mocks base method.

func (*MockBreakableResult) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBreakableResult) With

func (m *MockBreakableResult) With(format string, args ...any) Result

With mocks base method.

type MockBreakableResultMockRecorder

type MockBreakableResultMockRecorder struct {
	// contains filtered or unexported fields
}

MockBreakableResultMockRecorder is the mock recorder for MockBreakableResult.

func (*MockBreakableResultMockRecorder) Break

Break indicates an expected call of Break.

func (*MockBreakableResultMockRecorder) With

func (mr *MockBreakableResultMockRecorder) With(format any, args ...any) *gomock.Call

With indicates an expected call of With.

type MockContext

type MockContext[T any] struct {
	// contains filtered or unexported fields
}

MockContext is a mock of Context interface.

func NewMockContext

func NewMockContext[T any](ctrl *gomock.Controller) *MockContext[T]

NewMockContext creates a new mock instance.

func (*MockContext[T]) Deadline

func (m *MockContext[T]) Deadline() (time.Time, bool)

Deadline mocks base method.

func (*MockContext[T]) Done

func (m *MockContext[T]) Done() <-chan struct{}

Done mocks base method.

func (*MockContext[T]) EXPECT

func (m *MockContext[T]) EXPECT() *MockContextMockRecorder[T]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockContext[T]) Err

func (m *MockContext[T]) Err() error

Err mocks base method.

func (*MockContext[T]) Self

func (m *MockContext[T]) Self() *T

Self mocks base method.

func (*MockContext[T]) Value

func (m *MockContext[T]) Value(key any) any

Value mocks base method.

type MockContextMockRecorder

type MockContextMockRecorder[T any] struct {
	// contains filtered or unexported fields
}

MockContextMockRecorder is the mock recorder for MockContext.

func (*MockContextMockRecorder[T]) Deadline

func (mr *MockContextMockRecorder[T]) Deadline() *gomock.Call

Deadline indicates an expected call of Deadline.

func (*MockContextMockRecorder[T]) Done

func (mr *MockContextMockRecorder[T]) Done() *gomock.Call

Done indicates an expected call of Done.

func (*MockContextMockRecorder[T]) Err

func (mr *MockContextMockRecorder[T]) Err() *gomock.Call

Err indicates an expected call of Err.

func (*MockContextMockRecorder[T]) Self

func (mr *MockContextMockRecorder[T]) Self() *gomock.Call

Self indicates an expected call of Self.

func (*MockContextMockRecorder[T]) Value

func (mr *MockContextMockRecorder[T]) Value(key any) *gomock.Call

Value indicates an expected call of Value.

type MockContinuableResult

type MockContinuableResult struct {
	// contains filtered or unexported fields
}

MockContinuableResult is a mock of ContinuableResult interface.

func NewMockContinuableResult

func NewMockContinuableResult(ctrl *gomock.Controller) *MockContinuableResult

NewMockContinuableResult creates a new mock instance.

func (*MockContinuableResult) Continue

func (m *MockContinuableResult) Continue() WithMessage

Continue mocks base method.

func (*MockContinuableResult) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockContinuableResult) With

func (m *MockContinuableResult) With(format string, args ...any) Result

With mocks base method.

type MockContinuableResultMockRecorder

type MockContinuableResultMockRecorder struct {
	// contains filtered or unexported fields
}

MockContinuableResultMockRecorder is the mock recorder for MockContinuableResult.

func (*MockContinuableResultMockRecorder) Continue

Continue indicates an expected call of Continue.

func (*MockContinuableResultMockRecorder) With

func (mr *MockContinuableResultMockRecorder) With(format any, args ...any) *gomock.Call

With indicates an expected call of With.

type MockResult

type MockResult struct {
	// contains filtered or unexported fields
}

MockResult is a mock of Result interface.

func NewMockResult

func NewMockResult(ctrl *gomock.Controller) *MockResult

NewMockResult creates a new mock instance.

func (*MockResult) EXPECT

func (m *MockResult) EXPECT() *MockResultMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockResult) IsFailed

func (m *MockResult) IsFailed() bool

IsFailed mocks base method.

func (*MockResult) Message

func (m *MockResult) Message() string

Message mocks base method.

func (*MockResult) RequeueAfter

func (m *MockResult) RequeueAfter() time.Duration

RequeueAfter mocks base method.

func (*MockResult) ShouldContinue

func (m *MockResult) ShouldContinue() bool

ShouldContinue mocks base method.

type MockResultMockRecorder

type MockResultMockRecorder struct {
	// contains filtered or unexported fields
}

MockResultMockRecorder is the mock recorder for MockResult.

func (*MockResultMockRecorder) IsFailed

func (mr *MockResultMockRecorder) IsFailed() *gomock.Call

IsFailed indicates an expected call of IsFailed.

func (*MockResultMockRecorder) Message

func (mr *MockResultMockRecorder) Message() *gomock.Call

Message indicates an expected call of Message.

func (*MockResultMockRecorder) RequeueAfter

func (mr *MockResultMockRecorder) RequeueAfter() *gomock.Call

RequeueAfter indicates an expected call of RequeueAfter.

func (*MockResultMockRecorder) ShouldContinue

func (mr *MockResultMockRecorder) ShouldContinue() *gomock.Call

ShouldContinue indicates an expected call of ShouldContinue.

type MockTask

type MockTask[T any] struct {
	// contains filtered or unexported fields
}

MockTask is a mock of Task interface.

func NewMockTask

func NewMockTask[T any](ctrl *gomock.Controller) *MockTask[T]

NewMockTask creates a new mock instance.

func (*MockTask[T]) EXPECT

func (m *MockTask[T]) EXPECT() *MockTaskMockRecorder[T]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTask[T]) Name

func (m *MockTask[T]) Name() string

Name mocks base method.

func (*MockTask[T]) Sync

func (m *MockTask[T]) Sync(ctx Context[T]) Result

Sync mocks base method.

type MockTaskMockRecorder

type MockTaskMockRecorder[T any] struct {
	// contains filtered or unexported fields
}

MockTaskMockRecorder is the mock recorder for MockTask.

func (*MockTaskMockRecorder[T]) Name

func (mr *MockTaskMockRecorder[T]) Name() *gomock.Call

Name indicates an expected call of Name.

func (*MockTaskMockRecorder[T]) Sync

func (mr *MockTaskMockRecorder[T]) Sync(ctx any) *gomock.Call

Sync indicates an expected call of Sync.

type MockTaskReporter

type MockTaskReporter struct {
	// contains filtered or unexported fields
}

MockTaskReporter is a mock of TaskReporter interface.

func NewMockTaskReporter

func NewMockTaskReporter(ctrl *gomock.Controller) *MockTaskReporter

NewMockTaskReporter creates a new mock instance.

func (*MockTaskReporter) AddResult

func (m *MockTaskReporter) AddResult(name, status, msg string)

AddResult mocks base method.

func (*MockTaskReporter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTaskReporter) Summary

func (m *MockTaskReporter) Summary() string

Summary mocks base method.

type MockTaskReporterMockRecorder

type MockTaskReporterMockRecorder struct {
	// contains filtered or unexported fields
}

MockTaskReporterMockRecorder is the mock recorder for MockTaskReporter.

func (*MockTaskReporterMockRecorder) AddResult

func (mr *MockTaskReporterMockRecorder) AddResult(name, status, msg any) *gomock.Call

AddResult indicates an expected call of AddResult.

func (*MockTaskReporterMockRecorder) Summary

func (mr *MockTaskReporterMockRecorder) Summary() *gomock.Call

Summary indicates an expected call of Summary.

type MockTaskRunner

type MockTaskRunner[T any] struct {
	// contains filtered or unexported fields
}

MockTaskRunner is a mock of TaskRunner interface.

func NewMockTaskRunner

func NewMockTaskRunner[T any](ctrl *gomock.Controller) *MockTaskRunner[T]

NewMockTaskRunner creates a new mock instance.

func (*MockTaskRunner[T]) AddTasks

func (m *MockTaskRunner[T]) AddTasks(tasks ...Task[T])

AddTasks mocks base method.

func (*MockTaskRunner[T]) EXPECT

func (m *MockTaskRunner[T]) EXPECT() *MockTaskRunnerMockRecorder[T]

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTaskRunner[T]) Run

func (m *MockTaskRunner[T]) Run(ctx Context[T]) (controller_runtime.Result, error)

Run mocks base method.

type MockTaskRunnerMockRecorder

type MockTaskRunnerMockRecorder[T any] struct {
	// contains filtered or unexported fields
}

MockTaskRunnerMockRecorder is the mock recorder for MockTaskRunner.

func (*MockTaskRunnerMockRecorder[T]) AddTasks

func (mr *MockTaskRunnerMockRecorder[T]) AddTasks(tasks ...any) *gomock.Call

AddTasks indicates an expected call of AddTasks.

func (*MockTaskRunnerMockRecorder[T]) Run

func (mr *MockTaskRunnerMockRecorder[T]) Run(ctx any) *gomock.Call

Run indicates an expected call of Run.

type MockWithMessage

type MockWithMessage struct {
	// contains filtered or unexported fields
}

MockWithMessage is a mock of WithMessage interface.

func NewMockWithMessage

func NewMockWithMessage(ctrl *gomock.Controller) *MockWithMessage

NewMockWithMessage creates a new mock instance.

func (*MockWithMessage) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockWithMessage) With

func (m *MockWithMessage) With(format string, args ...any) Result

With mocks base method.

type MockWithMessageMockRecorder

type MockWithMessageMockRecorder struct {
	// contains filtered or unexported fields
}

MockWithMessageMockRecorder is the mock recorder for MockWithMessage.

func (*MockWithMessageMockRecorder) With

func (mr *MockWithMessageMockRecorder) With(format any, args ...any) *gomock.Call

With indicates an expected call of With.

type Result

type Result interface {
	IsFailed() bool
	ShouldContinue() bool
	RequeueAfter() time.Duration
	Message() string
}

Result defines the result of a task

type Task

type Task[T any] interface {
	Name() string
	Sync(ctx Context[T]) Result
}

Task defines a task can be executed by TaskRunner

type TaskReporter

type TaskReporter interface {
	AddResult(name, status, msg string)
	Summary() string
}

TaskReporter appends results of tasks and output a summary

func NewTableTaskReporter

func NewTableTaskReporter() TaskReporter

type TaskRunner

type TaskRunner[T any] interface {
	AddTasks(tasks ...Task[T])
	Run(ctx Context[T]) (ctrl.Result, error)
}

TaskRunner is an executor to run a series of tasks sequentially

func NewTaskRunner

func NewTaskRunner[T any](reporter TaskReporter) TaskRunner[T]

NewTaskRunner creates a TaskRunner with the given reporter and tasks. There are five status of tasks - Complete: means this task is complete and all is expected - Failed: means an err occurred - Retry: means this task need to wait an interval and retry - NotRun: means this task is not run - Skip: means this task is skipped And five results of reconiling 1. All tasks are complete, the key will not be re-added 2. Some tasks are failed, return err and wait with backoff 3. Some tasks need retry, requeue after an interval 4. Some tasks are not run, return err and wait with backoff 5. Particular tasks are complete and left are skipped, the key will not be re-added

type WithMessage

type WithMessage interface {
	With(format string, args ...any) Result
}

WithMessage defines an interface to set message into task result

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL