Documentation ¶
Overview ¶
Package tasks is a generated GoMock package.
Package tasks is a generated GoMock package.
Index ¶
- Constants
- Variables
- type ChannelQuotaRequestFn
- type ChannelWeightFn
- type FIFOScheduler
- type FIFOSchedulerOptions
- type InterleavedWeightedRoundRobinScheduler
- type InterleavedWeightedRoundRobinSchedulerOptions
- type MockScheduler
- type MockSchedulerMockRecorder
- type MockTask
- func (m *MockTask) Ack()
- func (m *MockTask) Cancel()
- 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) Cancel() *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 Monitor
- type Priority
- type Scheduler
- type State
- type Task
- type TaskChannelKeyFn
- type TaskChannelMetricTagsFn
- type WeightedChannel
- type WeightedChannels
Constants ¶
const (
WeightedChannelDefaultSize = 1000
)
Variables ¶
var ( PriorityHigh = getPriority(highPriorityClass, mediumPrioritySubclass) PriorityLow = getPriority(lowPriorityClass, mediumPrioritySubclass) )
var ( PriorityName = map[Priority]string{ PriorityHigh: "high", PriorityLow: "low", } PriorityValue = map[string]Priority{ "high": PriorityHigh, "low": PriorityLow, } )
Functions ¶
This section is empty.
Types ¶
type ChannelQuotaRequestFn ¶ added in v1.19.0
type ChannelQuotaRequestFn[K comparable] func(K) quotas.Request
ChannelQuotaRequestFn is the function for mapping a task channel (key) to its rate limit request
type ChannelWeightFn ¶ added in v1.18.0
type ChannelWeightFn[K comparable] func(K) int
ChannelWeightFn is the function for mapping a task channel (key) to its weight
type FIFOScheduler ¶ added in v1.18.0
type FIFOScheduler[T Task] struct { // contains filtered or unexported fields }
func NewFIFOScheduler ¶ added in v1.18.0
func NewFIFOScheduler[T Task]( scheduleMoniter Monitor[T], options *FIFOSchedulerOptions, logger log.Logger, ) *FIFOScheduler[T]
NewFIFOScheduler creates a new FIFOScheduler
func (*FIFOScheduler[T]) Start ¶ added in v1.18.0
func (f *FIFOScheduler[T]) Start()
func (*FIFOScheduler[T]) Stop ¶ added in v1.18.0
func (f *FIFOScheduler[T]) Stop()
func (*FIFOScheduler[T]) Submit ¶ added in v1.18.0
func (f *FIFOScheduler[T]) Submit(task T)
func (*FIFOScheduler[T]) TrySubmit ¶ added in v1.18.0
func (f *FIFOScheduler[T]) TrySubmit(task T) bool
type FIFOSchedulerOptions ¶ added in v1.18.0
type FIFOSchedulerOptions struct { QueueSize int WorkerCount dynamicconfig.IntPropertyFn }
FIFOSchedulerOptions is the configs for FIFOScheduler
type InterleavedWeightedRoundRobinScheduler ¶ added in v1.14.0
type InterleavedWeightedRoundRobinScheduler[T Task, K comparable] 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[T Task, K comparable]( options InterleavedWeightedRoundRobinSchedulerOptions[T, K], fifoScheduler Scheduler[T], rateLimiter quotas.RequestRateLimiter, timeSource clock.TimeSource, logger log.Logger, metricsHandler metrics.Handler, ) *InterleavedWeightedRoundRobinScheduler[T, K]
func (*InterleavedWeightedRoundRobinScheduler[T, K]) Start ¶ added in v1.14.0
func (s *InterleavedWeightedRoundRobinScheduler[T, K]) Start()
func (*InterleavedWeightedRoundRobinScheduler[T, K]) Stop ¶ added in v1.14.0
func (s *InterleavedWeightedRoundRobinScheduler[T, K]) Stop()
type InterleavedWeightedRoundRobinSchedulerOptions ¶ added in v1.14.0
type InterleavedWeightedRoundRobinSchedulerOptions[T Task, K comparable] struct { // Required for mapping a task to it's corresponding task channel TaskChannelKeyFn TaskChannelKeyFn[T, K] // Required for getting the weight for a task channel ChannelWeightFn ChannelWeightFn[K] // Optional, if specified, re-evaluate task channel weight when channel is not empty ChannelWeightUpdateCh chan struct{} // Required for converting task channel to rate limit request ChannelQuotaRequestFn ChannelQuotaRequestFn[K] // Required for getting metrics tags for task channels TaskChannelMetricTagsFn TaskChannelMetricTagsFn[K] // Required for determining if rate limiter should be enabled EnableRateLimiter dynamicconfig.BoolPropertyFn // Required for determining if task should still go through rate limiter and // emit metrics, but not actually block task dispatching. // only takes effect when rate limiter is not enabled EnableRateLimiterShadowMode dynamicconfig.BoolPropertyFn // Required for determining how long scheduler should be throttled // when exceeding allowed dispatch rate DispatchThrottleDuration dynamicconfig.DurationPropertyFn }
InterleavedWeightedRoundRobinSchedulerOptions is the config for interleaved weighted round robin scheduler
type MockScheduler ¶ added in v1.14.0
type MockScheduler[T Task] struct { // contains filtered or unexported fields }
MockScheduler is a mock of Scheduler interface.
func NewMockScheduler ¶ added in v1.14.0
func NewMockScheduler[T Task](ctrl *gomock.Controller) *MockScheduler[T]
NewMockScheduler creates a new mock instance.
func (*MockScheduler[T]) EXPECT ¶ added in v1.14.0
func (m *MockScheduler[T]) EXPECT() *MockSchedulerMockRecorder[T]
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockScheduler[T]) Start ¶ added in v1.14.0
func (m *MockScheduler[T]) Start()
Start mocks base method.
func (*MockScheduler[T]) Stop ¶ added in v1.14.0
func (m *MockScheduler[T]) Stop()
Stop mocks base method.
func (*MockScheduler[T]) Submit ¶ added in v1.14.0
func (m *MockScheduler[T]) Submit(task T)
Submit mocks base method.
func (*MockScheduler[T]) TrySubmit ¶ added in v1.17.0
func (m *MockScheduler[T]) TrySubmit(task T) bool
TrySubmit mocks base method.
type MockSchedulerMockRecorder ¶ added in v1.14.0
type MockSchedulerMockRecorder[T Task] struct { // contains filtered or unexported fields }
MockSchedulerMockRecorder is the mock recorder for MockScheduler.
func (*MockSchedulerMockRecorder[T]) Start ¶ added in v1.14.0
func (mr *MockSchedulerMockRecorder[T]) Start() *gomock.Call
Start indicates an expected call of Start.
func (*MockSchedulerMockRecorder[T]) Stop ¶ added in v1.14.0
func (mr *MockSchedulerMockRecorder[T]) Stop() *gomock.Call
Stop indicates an expected call of Stop.
func (*MockSchedulerMockRecorder[T]) Submit ¶ added in v1.14.0
func (mr *MockSchedulerMockRecorder[T]) Submit(task interface{}) *gomock.Call
Submit indicates an expected call of Submit.
func (*MockSchedulerMockRecorder[T]) TrySubmit ¶ added in v1.17.0
func (mr *MockSchedulerMockRecorder[T]) 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) Cancel ¶ added in v1.17.3
func (mr *MockTaskMockRecorder) Cancel() *gomock.Call
Cancel indicates an expected call of Cancel.
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 Scheduler ¶ added in v1.14.0
Scheduler is the generic interface for scheduling & processing tasks
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 // TaskStateCancelled is the state for a task when its execution has request to be cancelled TaskStateCancelled // 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 // Cancel requests cancellation for processing the task Cancel() // 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 TaskChannelKeyFn ¶ added in v1.18.0
type TaskChannelKeyFn[T Task, K comparable] func(T) K
TaskChannelKeyFn is the function for mapping a task to its task channel (key)
type TaskChannelMetricTagsFn ¶ added in v1.20.0
type TaskChannelMetricTagsFn[K comparable] func(K) []metrics.Tag
TaskChannelMetricTagsFn is the function for mapping a task channel (key) to its metrics tags
type WeightedChannel ¶ added in v1.14.0
type WeightedChannel[T Task] struct { // contains filtered or unexported fields }
func NewWeightedChannel ¶ added in v1.14.0
type WeightedChannels ¶ added in v1.14.0
type WeightedChannels[T Task] []*WeightedChannel[T]
func (WeightedChannels[T]) Len ¶ added in v1.14.0
func (c WeightedChannels[T]) Len() int
func (WeightedChannels[T]) Less ¶ added in v1.14.0
func (c WeightedChannels[T]) Less(i, j int) bool
func (WeightedChannels[T]) Swap ¶ added in v1.14.0
func (c WeightedChannels[T]) Swap(i, j int)