tasks

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 10 Imported by: 0

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

View Source
const (
	WeightedChannelDefaultSize = 100
)

Variables

This section is empty.

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,
	priorityToWeight map[int]int,
	processor Processor,
	metricsClient metrics.Client,
	logger log.Logger,
) *InterleavedWeightedRoundRobinScheduler

func (*InterleavedWeightedRoundRobinScheduler) Start added in v1.14.0

func (*InterleavedWeightedRoundRobinScheduler) Stop added in v1.14.0

func (*InterleavedWeightedRoundRobinScheduler) Submit added in v1.14.0

type InterleavedWeightedRoundRobinSchedulerOptions added in v1.14.0

type InterleavedWeightedRoundRobinSchedulerOptions struct {
	QueueSize   int
	WorkerCount int
}

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

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() int

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()

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 int)

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

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

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

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

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

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

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.

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

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.

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) Ack added in v1.14.0

func (m *MockTask) Ack()

Ack mocks base method.

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) Execute added in v1.14.0

func (m *MockTask) Execute() error

Execute mocks base method.

func (*MockTask) HandleErr added in v1.14.0

func (m *MockTask) HandleErr(err error) error

HandleErr mocks base method.

func (*MockTask) IsRetryableError added in v1.14.0

func (m *MockTask) IsRetryableError(err error) bool

IsRetryableError mocks base method.

func (*MockTask) Nack added in v1.14.0

func (m *MockTask) Nack()

Nack 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.

func (*MockTask) State added in v1.14.0

func (m *MockTask) State() State

State 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() *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,
	metricsClient metrics.Client,
	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 int
}

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() int
	// SetPriority sets the priority of the task
	SetPriority(int)
}

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)
}

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()
	// 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)

Jump to

Keyboard shortcuts

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