task

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockSequentialTaskProcessor

type MockSequentialTaskProcessor struct {
	mock.Mock
}

MockSequentialTaskProcessor is an autogenerated mock type for the SequentialTaskProcessor type

func (*MockSequentialTaskProcessor) Start

func (_m *MockSequentialTaskProcessor) Start()

Start provides a mock function with given fields:

func (*MockSequentialTaskProcessor) Stop

func (_m *MockSequentialTaskProcessor) Stop()

Stop provides a mock function with given fields:

func (*MockSequentialTaskProcessor) Submit

Submit provides a mock function with given fields: _a0

type SequentialTask

type SequentialTask interface {
	// Execute process this task
	Execute() error
	// HandleErr handle the error returned by Execute
	HandleErr(err error) error
	// RetryErr check whether to retry after HandleErr(Execute())
	RetryErr(err error) bool
	// Ack marks the task as successful completed
	Ack()
	// Nack marks the task as unsuccessful completed
	Nack()
}

SequentialTask is the interface for tasks which should be executed sequentially

type SequentialTaskProcessor

type SequentialTaskProcessor interface {
	common.Daemon
	Submit(task SequentialTask) error
}

SequentialTaskProcessor is the generic coroutine pool interface which process sequential task

func NewSequentialTaskProcessor

func NewSequentialTaskProcessor(coroutineSize int, taskQueueHashFn collection.HashFunc, taskQueueFactory SequentialTaskQueueFactory,
	metricsClient metrics.Client, logger log.Logger) SequentialTaskProcessor

NewSequentialTaskProcessor create a new sequential tasks processor

type SequentialTaskQueue added in v0.5.8

type SequentialTaskQueue interface {
	// QueueID return the ID of the queue, as well as the tasks inside (same)
	QueueID() interface{}
	// Offer push an task to the task set
	Add(task SequentialTask)
	// Poll pop an task from the task set
	Remove() SequentialTask
	// IsEmpty indicate if the task set is empty
	IsEmpty() bool
	// Len return the size of the queue
	Len() int
}

SequentialTaskQueue is the generic task queue interface which group sequential tasks to be executed one by one

type SequentialTaskQueueFactory added in v0.5.8

type SequentialTaskQueueFactory func(task SequentialTask) SequentialTaskQueue

SequentialTaskQueueFactory is the function which generate a new SequentialTaskQueue for a give SequentialTask

Jump to

Keyboard shortcuts

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