executor

package
v1.2.11 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// Start starts the executor
	Start()
	// Stop stops the executor
	Stop()
	// Submit is a blocking call that accepts a task to execute
	Submit(task Task) bool
	// TaskCount returns the number of outstanding tasks in the executor
	TaskCount() int64
}

Executor defines the interface for any executor which can accept tasks and execute them based on some policy

func NewFixedSizePoolExecutor

func NewFixedSizePoolExecutor(size int, maxDeferred int, metrics metrics.Client, scope int) Executor

NewFixedSizePoolExecutor returns an implementation of task executor that maintains a fixed size pool of goroutines.The returned executor also allows task processing to to be deferred for fairness. To defer processing of a task, simply return TaskStatsDefer from your task.Run method. When a task is deferred, it will be added to the tail of a deferredTaskQ which in turn will be processed after the current runQ is drained

type Task

type Task interface {
	// Run should execute the task and return well known status codes
	Run() TaskStatus
}

Task defines the interface for a runnable task

type TaskStatus

type TaskStatus int

TaskStatus is the return code from a Task

const (
	// TaskStatusDone indicates task is finished successfully
	TaskStatusDone TaskStatus = iota
	// TaskStatusDefer indicates task should be scheduled again for execution at later time
	TaskStatusDefer
	// TaskStatusErr indicates task is finished with errors
	TaskStatusErr
)

Jump to

Keyboard shortcuts

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