Documentation ¶
Overview ¶
Package tasks is a generated GoMock package.
Package tasks is a generated GoMock package.
Package tasks is a generated GoMock package.
Index ¶
- Constants
- Variables
- type InterleavedWeightedRoundRobinScheduler
- type InterleavedWeightedRoundRobinSchedulerOptions
- type MockPriorityTask
- func (m *MockPriorityTask) Ack()
- func (m *MockPriorityTask) EXPECT() *MockPriorityTaskMockRecorder
- func (m *MockPriorityTask) Execute() error
- func (m *MockPriorityTask) GetPriority() Priority
- func (m *MockPriorityTask) HandleErr(err error) error
- func (m *MockPriorityTask) IsRetryableError(err error) bool
- func (m *MockPriorityTask) Nack(err error)
- func (m *MockPriorityTask) Reschedule()
- func (m *MockPriorityTask) RetryPolicy() backoff.RetryPolicy
- func (m *MockPriorityTask) SetPriority(arg0 Priority)
- func (m *MockPriorityTask) State() State
- type MockPriorityTaskMockRecorder
- func (mr *MockPriorityTaskMockRecorder) Ack() *gomock.Call
- func (mr *MockPriorityTaskMockRecorder) Execute() *gomock.Call
- func (mr *MockPriorityTaskMockRecorder) GetPriority() *gomock.Call
- func (mr *MockPriorityTaskMockRecorder) HandleErr(err interface{}) *gomock.Call
- func (mr *MockPriorityTaskMockRecorder) IsRetryableError(err interface{}) *gomock.Call
- func (mr *MockPriorityTaskMockRecorder) Nack(err interface{}) *gomock.Call
- func (mr *MockPriorityTaskMockRecorder) Reschedule() *gomock.Call
- func (mr *MockPriorityTaskMockRecorder) RetryPolicy() *gomock.Call
- func (mr *MockPriorityTaskMockRecorder) SetPriority(arg0 interface{}) *gomock.Call
- func (mr *MockPriorityTaskMockRecorder) State() *gomock.Call
- type MockProcessor
- type MockProcessorMockRecorder
- type MockScheduler
- type MockSchedulerMockRecorder
- type MockTask
- func (m *MockTask) Ack()
- func (m *MockTask) EXPECT() *MockTaskMockRecorder
- func (m *MockTask) Execute() error
- func (m *MockTask) HandleErr(err error) error
- func (m *MockTask) IsRetryableError(err error) bool
- func (m *MockTask) Nack(err error)
- func (m *MockTask) Reschedule()
- func (m *MockTask) RetryPolicy() backoff.RetryPolicy
- func (m *MockTask) State() State
- type MockTaskMockRecorder
- func (mr *MockTaskMockRecorder) Ack() *gomock.Call
- func (mr *MockTaskMockRecorder) Execute() *gomock.Call
- func (mr *MockTaskMockRecorder) HandleErr(err interface{}) *gomock.Call
- func (mr *MockTaskMockRecorder) IsRetryableError(err interface{}) *gomock.Call
- func (mr *MockTaskMockRecorder) Nack(err interface{}) *gomock.Call
- func (mr *MockTaskMockRecorder) Reschedule() *gomock.Call
- func (mr *MockTaskMockRecorder) RetryPolicy() *gomock.Call
- func (mr *MockTaskMockRecorder) State() *gomock.Call
- type ParallelProcessor
- type ParallelProcessorOptions
- type Priority
- type PriorityTask
- type Processor
- type Scheduler
- type State
- type Task
- type WeightedChannel
- type WeightedChannels
Constants ¶
const ( OperationTaskScheduler = "TaskScheduler" OperationParallelTaskProcessing = "ParallelTaskProcessing" )
const (
WeightedChannelDefaultSize = 10000
)
Variables ¶
var ( PriorityHigh = getPriority(highPriorityClass, mediumPrioritySubclass) PriorityMedium = getPriority(mediumPriorityClass, mediumPrioritySubclass) PriorityLow = getPriority(lowPriorityClass, mediumPrioritySubclass) )
var ( PriorityName = map[Priority]string{ PriorityHigh: "high", PriorityMedium: "medium", PriorityLow: "low", } PriorityValue = map[string]Priority{ "high": PriorityHigh, "medium": PriorityMedium, "low": PriorityLow, } )
Functions ¶
This section is empty.
Types ¶
type InterleavedWeightedRoundRobinScheduler ¶ added in v1.14.0
type InterleavedWeightedRoundRobinScheduler struct { sync.RWMutex // contains filtered or unexported fields }
InterleavedWeightedRoundRobinScheduler is a round robin scheduler implementation ref: https://en.wikipedia.org/wiki/Weighted_round_robin#Interleaved_WRR
func NewInterleavedWeightedRoundRobinScheduler ¶ added in v1.14.0
func NewInterleavedWeightedRoundRobinScheduler( option InterleavedWeightedRoundRobinSchedulerOptions, processor Processor, metricsProvider metrics.MetricsHandler, logger log.Logger, ) *InterleavedWeightedRoundRobinScheduler
func (*InterleavedWeightedRoundRobinScheduler) Start ¶ added in v1.14.0
func (s *InterleavedWeightedRoundRobinScheduler) Start()
func (*InterleavedWeightedRoundRobinScheduler) Stop ¶ added in v1.14.0
func (s *InterleavedWeightedRoundRobinScheduler) Stop()
func (*InterleavedWeightedRoundRobinScheduler) Submit ¶ added in v1.14.0
func (s *InterleavedWeightedRoundRobinScheduler) Submit( task PriorityTask, )
func (*InterleavedWeightedRoundRobinScheduler) TrySubmit ¶ added in v1.17.0
func (s *InterleavedWeightedRoundRobinScheduler) TrySubmit( task PriorityTask, ) bool
type InterleavedWeightedRoundRobinSchedulerOptions ¶ added in v1.14.0
InterleavedWeightedRoundRobinSchedulerOptions is the config for interleaved weighted round robin scheduler
type MockPriorityTask ¶ added in v1.14.0
type MockPriorityTask struct {
// contains filtered or unexported fields
}
MockPriorityTask is a mock of PriorityTask interface.
func NewMockPriorityTask ¶ added in v1.14.0
func NewMockPriorityTask(ctrl *gomock.Controller) *MockPriorityTask
NewMockPriorityTask creates a new mock instance.
func (*MockPriorityTask) Ack ¶ added in v1.14.0
func (m *MockPriorityTask) Ack()
Ack mocks base method.
func (*MockPriorityTask) EXPECT ¶ added in v1.14.0
func (m *MockPriorityTask) EXPECT() *MockPriorityTaskMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPriorityTask) Execute ¶ added in v1.14.0
func (m *MockPriorityTask) Execute() error
Execute mocks base method.
func (*MockPriorityTask) GetPriority ¶ added in v1.14.0
func (m *MockPriorityTask) GetPriority() Priority
GetPriority mocks base method.
func (*MockPriorityTask) HandleErr ¶ added in v1.14.0
func (m *MockPriorityTask) HandleErr(err error) error
HandleErr mocks base method.
func (*MockPriorityTask) IsRetryableError ¶ added in v1.14.0
func (m *MockPriorityTask) IsRetryableError(err error) bool
IsRetryableError mocks base method.
func (*MockPriorityTask) Nack ¶ added in v1.14.0
func (m *MockPriorityTask) Nack(err error)
Nack mocks base method.
func (*MockPriorityTask) Reschedule ¶ added in v1.14.0
func (m *MockPriorityTask) Reschedule()
Reschedule mocks base method.
func (*MockPriorityTask) RetryPolicy ¶ added in v1.14.0
func (m *MockPriorityTask) RetryPolicy() backoff.RetryPolicy
RetryPolicy mocks base method.
func (*MockPriorityTask) SetPriority ¶ added in v1.14.0
func (m *MockPriorityTask) SetPriority(arg0 Priority)
SetPriority mocks base method.
func (*MockPriorityTask) State ¶ added in v1.14.0
func (m *MockPriorityTask) State() State
State mocks base method.
type MockPriorityTaskMockRecorder ¶ added in v1.14.0
type MockPriorityTaskMockRecorder struct {
// contains filtered or unexported fields
}
MockPriorityTaskMockRecorder is the mock recorder for MockPriorityTask.
func (*MockPriorityTaskMockRecorder) Ack ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) Ack() *gomock.Call
Ack indicates an expected call of Ack.
func (*MockPriorityTaskMockRecorder) Execute ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) Execute() *gomock.Call
Execute indicates an expected call of Execute.
func (*MockPriorityTaskMockRecorder) GetPriority ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) GetPriority() *gomock.Call
GetPriority indicates an expected call of GetPriority.
func (*MockPriorityTaskMockRecorder) HandleErr ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) HandleErr(err interface{}) *gomock.Call
HandleErr indicates an expected call of HandleErr.
func (*MockPriorityTaskMockRecorder) IsRetryableError ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) IsRetryableError(err interface{}) *gomock.Call
IsRetryableError indicates an expected call of IsRetryableError.
func (*MockPriorityTaskMockRecorder) Nack ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) Nack(err interface{}) *gomock.Call
Nack indicates an expected call of Nack.
func (*MockPriorityTaskMockRecorder) Reschedule ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) Reschedule() *gomock.Call
Reschedule indicates an expected call of Reschedule.
func (*MockPriorityTaskMockRecorder) RetryPolicy ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) RetryPolicy() *gomock.Call
RetryPolicy indicates an expected call of RetryPolicy.
func (*MockPriorityTaskMockRecorder) SetPriority ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) SetPriority(arg0 interface{}) *gomock.Call
SetPriority indicates an expected call of SetPriority.
func (*MockPriorityTaskMockRecorder) State ¶ added in v1.14.0
func (mr *MockPriorityTaskMockRecorder) State() *gomock.Call
State indicates an expected call of State.
type MockProcessor ¶ added in v1.14.0
type MockProcessor struct {
// contains filtered or unexported fields
}
MockProcessor is a mock of Processor interface.
func NewMockProcessor ¶ added in v1.14.0
func NewMockProcessor(ctrl *gomock.Controller) *MockProcessor
NewMockProcessor creates a new mock instance.
func (*MockProcessor) EXPECT ¶ added in v1.14.0
func (m *MockProcessor) EXPECT() *MockProcessorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockProcessor) Start ¶ added in v1.14.0
func (m *MockProcessor) Start()
Start mocks base method.
func (*MockProcessor) Stop ¶ added in v1.14.0
func (m *MockProcessor) Stop()
Stop mocks base method.
func (*MockProcessor) Submit ¶ added in v1.14.0
func (m *MockProcessor) Submit(task Task)
Submit mocks base method.
type MockProcessorMockRecorder ¶ added in v1.14.0
type MockProcessorMockRecorder struct {
// contains filtered or unexported fields
}
MockProcessorMockRecorder is the mock recorder for MockProcessor.
func (*MockProcessorMockRecorder) Start ¶ added in v1.14.0
func (mr *MockProcessorMockRecorder) Start() *gomock.Call
Start indicates an expected call of Start.
func (*MockProcessorMockRecorder) Stop ¶ added in v1.14.0
func (mr *MockProcessorMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop.
func (*MockProcessorMockRecorder) Submit ¶ added in v1.14.0
func (mr *MockProcessorMockRecorder) Submit(task interface{}) *gomock.Call
Submit indicates an expected call of Submit.
type MockScheduler ¶ added in v1.14.0
type MockScheduler struct {
// contains filtered or unexported fields
}
MockScheduler is a mock of Scheduler interface.
func NewMockScheduler ¶ added in v1.14.0
func NewMockScheduler(ctrl *gomock.Controller) *MockScheduler
NewMockScheduler creates a new mock instance.
func (*MockScheduler) EXPECT ¶ added in v1.14.0
func (m *MockScheduler) EXPECT() *MockSchedulerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockScheduler) Start ¶ added in v1.14.0
func (m *MockScheduler) Start()
Start mocks base method.
func (*MockScheduler) Stop ¶ added in v1.14.0
func (m *MockScheduler) Stop()
Stop mocks base method.
func (*MockScheduler) Submit ¶ added in v1.14.0
func (m *MockScheduler) Submit(task PriorityTask)
Submit mocks base method.
func (*MockScheduler) TrySubmit ¶ added in v1.17.0
func (m *MockScheduler) TrySubmit(task PriorityTask) bool
TrySubmit mocks base method.
type MockSchedulerMockRecorder ¶ added in v1.14.0
type MockSchedulerMockRecorder struct {
// contains filtered or unexported fields
}
MockSchedulerMockRecorder is the mock recorder for MockScheduler.
func (*MockSchedulerMockRecorder) Start ¶ added in v1.14.0
func (mr *MockSchedulerMockRecorder) Start() *gomock.Call
Start indicates an expected call of Start.
func (*MockSchedulerMockRecorder) Stop ¶ added in v1.14.0
func (mr *MockSchedulerMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop.
func (*MockSchedulerMockRecorder) Submit ¶ added in v1.14.0
func (mr *MockSchedulerMockRecorder) Submit(task interface{}) *gomock.Call
Submit indicates an expected call of Submit.
func (*MockSchedulerMockRecorder) TrySubmit ¶ added in v1.17.0
func (mr *MockSchedulerMockRecorder) TrySubmit(task interface{}) *gomock.Call
TrySubmit indicates an expected call of TrySubmit.
type MockTask ¶ added in v1.14.0
type MockTask struct {
// contains filtered or unexported fields
}
MockTask is a mock of Task interface.
func NewMockTask ¶ added in v1.14.0
func NewMockTask(ctrl *gomock.Controller) *MockTask
NewMockTask creates a new mock instance.
func (*MockTask) EXPECT ¶ added in v1.14.0
func (m *MockTask) EXPECT() *MockTaskMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTask) IsRetryableError ¶ added in v1.14.0
IsRetryableError mocks base method.
func (*MockTask) Reschedule ¶ added in v1.14.0
func (m *MockTask) Reschedule()
Reschedule mocks base method.
func (*MockTask) RetryPolicy ¶ added in v1.14.0
func (m *MockTask) RetryPolicy() backoff.RetryPolicy
RetryPolicy mocks base method.
type MockTaskMockRecorder ¶ added in v1.14.0
type MockTaskMockRecorder struct {
// contains filtered or unexported fields
}
MockTaskMockRecorder is the mock recorder for MockTask.
func (*MockTaskMockRecorder) Ack ¶ added in v1.14.0
func (mr *MockTaskMockRecorder) Ack() *gomock.Call
Ack indicates an expected call of Ack.
func (*MockTaskMockRecorder) Execute ¶ added in v1.14.0
func (mr *MockTaskMockRecorder) Execute() *gomock.Call
Execute indicates an expected call of Execute.
func (*MockTaskMockRecorder) HandleErr ¶ added in v1.14.0
func (mr *MockTaskMockRecorder) HandleErr(err interface{}) *gomock.Call
HandleErr indicates an expected call of HandleErr.
func (*MockTaskMockRecorder) IsRetryableError ¶ added in v1.14.0
func (mr *MockTaskMockRecorder) IsRetryableError(err interface{}) *gomock.Call
IsRetryableError indicates an expected call of IsRetryableError.
func (*MockTaskMockRecorder) Nack ¶ added in v1.14.0
func (mr *MockTaskMockRecorder) Nack(err interface{}) *gomock.Call
Nack indicates an expected call of Nack.
func (*MockTaskMockRecorder) Reschedule ¶ added in v1.14.0
func (mr *MockTaskMockRecorder) Reschedule() *gomock.Call
Reschedule indicates an expected call of Reschedule.
func (*MockTaskMockRecorder) RetryPolicy ¶ added in v1.14.0
func (mr *MockTaskMockRecorder) RetryPolicy() *gomock.Call
RetryPolicy indicates an expected call of RetryPolicy.
func (*MockTaskMockRecorder) State ¶ added in v1.14.0
func (mr *MockTaskMockRecorder) State() *gomock.Call
State indicates an expected call of State.
type ParallelProcessor ¶ added in v1.14.0
type ParallelProcessor struct {
// contains filtered or unexported fields
}
func NewParallelProcessor ¶ added in v1.14.0
func NewParallelProcessor( options *ParallelProcessorOptions, metricsProvider metrics.MetricsHandler, logger log.Logger, ) *ParallelProcessor
NewParallelProcessor creates a new ParallelProcessor
func (*ParallelProcessor) Start ¶ added in v1.14.0
func (p *ParallelProcessor) Start()
func (*ParallelProcessor) Stop ¶ added in v1.14.0
func (p *ParallelProcessor) Stop()
func (*ParallelProcessor) Submit ¶ added in v1.14.0
func (p *ParallelProcessor) Submit(task Task)
type ParallelProcessorOptions ¶ added in v1.14.0
type ParallelProcessorOptions struct { QueueSize int WorkerCount dynamicconfig.IntPropertyFn }
ParallelProcessorOptions is the configs for ParallelProcessor
type PriorityTask ¶ added in v1.14.0
type PriorityTask interface { Task // GetPriority returns the priority of the task GetPriority() Priority // SetPriority sets the priority of the task SetPriority(Priority) }
PriorityTask is the interface for tasks which have and can be assigned a priority
type Processor ¶ added in v1.14.0
type Processor interface { common.Daemon // Submit schedule a task to be executed // * if processor is not stopped, then task will be executed, // one of Ack(), Nack() or Reschedule() will be invoked once task is considered done for this attempt // * if processor is stopped, then Reschedule() will be invoked Submit(task Task) }
Processor is the generic goroutine pool for task processing
type Scheduler ¶ added in v1.14.0
type Scheduler interface { common.Daemon Submit(task PriorityTask) TrySubmit(task PriorityTask) bool }
Scheduler is the generic interface for scheduling & processing tasks with priority
type State ¶ added in v1.14.0
type State int
State represents the current state of a task
const ( // TaskStatePending is the state for a task when it's waiting to be processed or currently being processed TaskStatePending State = iota + 1 // TaskStateAcked is the state for a task if it has been successfully completed TaskStateAcked // TaskStateNacked is the state for a task if it can not be processed TaskStateNacked )
type Task ¶
type Task interface { // Execute process this task Execute() error // HandleErr handle the error returned by Execute HandleErr(err error) error // IsRetryableError check whether to retry after HandleErr(Execute()) IsRetryableError(err error) bool // RetryPolicy returns the retry policy for task processing RetryPolicy() backoff.RetryPolicy // Ack marks the task as successful completed Ack() // Nack marks the task as unsuccessful completed Nack(err error) // Reschedule marks the task for retry Reschedule() // State returns the current task state State() State }
Task is the interface for tasks which should be executed sequentially
type WeightedChannel ¶ added in v1.14.0
type WeightedChannel struct {
// contains filtered or unexported fields
}
func NewWeightedChannel ¶ added in v1.14.0
func NewWeightedChannel( weight int, size int, ) *WeightedChannel
func (*WeightedChannel) Cap ¶ added in v1.14.0
func (c *WeightedChannel) Cap() int
func (*WeightedChannel) Chan ¶ added in v1.14.0
func (c *WeightedChannel) Chan() chan PriorityTask
func (*WeightedChannel) Len ¶ added in v1.14.0
func (c *WeightedChannel) Len() int
func (*WeightedChannel) Weight ¶ added in v1.14.0
func (c *WeightedChannel) Weight() int
type WeightedChannels ¶ added in v1.14.0
type WeightedChannels []*WeightedChannel
func (WeightedChannels) Len ¶ added in v1.14.0
func (c WeightedChannels) Len() int
func (WeightedChannels) Less ¶ added in v1.14.0
func (c WeightedChannels) Less(i, j int) bool
func (WeightedChannels) Swap ¶ added in v1.14.0
func (c WeightedChannels) Swap(i, j int)