executor

package
v0.0.0-...-436d200 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	Process(req Request) *sync.WaitGroup
	ProcessWithWaitGroup(r Request, wg *sync.WaitGroup)
}

type InlineableRequest

type InlineableRequest interface {
	Request

	CanExecuteInline()
}

If the request implements the InlineableRequest interface, the executor may process the request using the Process/ProcessWithGroupGroup's caller goroutine.

NOTE: The executor will only look at the CanExecuteInline method signature (it will not invoke the method).

type Request

type Request interface {
	// The executor will call this method to serve the request.
	Execute()

	// The executor will call this method if the executor cannot serve the
	// request.  Cancel should be a cheap operation than Execute.
	Cancel()
}

type WorkPoolExecutor

type WorkPoolExecutor struct {
	// contains filtered or unexported fields
}

Process requests using a fixed number of workers (when configured) to limit concurrency. Requests are processed in LIFO order.

NOTE: When the number of workers is set to unlimited, the executor may process the request using the Process/ProcessWithWaitGroup's caller goroutine if the request implements the InlineableRequest interface.

func NewWorkPoolExecutor

func NewWorkPoolExecutor() *WorkPoolExecutor

func (*WorkPoolExecutor) Configure

func (p *WorkPoolExecutor) Configure(params WorkPoolExecutorParams) error

func (*WorkPoolExecutor) HighWaterMark

func (p *WorkPoolExecutor) HighWaterMark() int

func (*WorkPoolExecutor) NumWorkers

func (p *WorkPoolExecutor) NumWorkers() int

func (*WorkPoolExecutor) Params

func (*WorkPoolExecutor) Process

func (p *WorkPoolExecutor) Process(req Request) *sync.WaitGroup

func (*WorkPoolExecutor) ProcessWithWaitGroup

func (p *WorkPoolExecutor) ProcessWithWaitGroup(r Request, wg *sync.WaitGroup)

func (*WorkPoolExecutor) Size

func (p *WorkPoolExecutor) Size() int

type WorkPoolExecutorParams

type WorkPoolExecutorParams struct {
	// The number of worker in this pool.  Non-positive means unlimited.
	NumWorkers int

	// The amount of time a request can be in the queue before the request
	// gets cancelled.  If the value is non-positive, timeout is disabled.
	QueueTimeout time.Duration

	// How frequent should the work pool sweeps timed out requests from its
	// queue. CheckInterval must by positive when QueueTimeout is enabled.
	CheckInterval time.Duration
}

Jump to

Keyboard shortcuts

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