executor

package
v0.0.0-...-26ab6e5 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentExecutor

type ConcurrentExecutor[T any] struct {
	Config   ConcurrentExecutorConfig
	Delegate delegate.Delegate[T]
	// contains filtered or unexported fields
}

ConcurrentExecutor is the concurrency-backed implementation of Executor. This implementation executes tasks in different goroutines and reduces host's resource exhaustion by using a semaphore (can be configured with ConcurrentExecutorConfig).

func (*ConcurrentExecutor[T]) ExecuteAll

func (s *ConcurrentExecutor[T]) ExecuteAll(ctx context.Context, args []T) error

type ConcurrentExecutorConfig

type ConcurrentExecutorConfig struct {
	MaxGoroutines int64
}

type Executor

type Executor[T any] interface {
	// ExecuteAll executes all tasks.
	ExecuteAll(ctx context.Context, args []T) error
}

Executor is a core component that allows routines to execute delegate.Delegate routines with specified arguments (T) in an abstract way. It will depend on which kind of concrete implementation how these delegate routines will be executed.

Use ConcurrentExecutor to execute routines in a concurrent way. On the other hand, use SyncExecutor to execute tasks sequentially.

type SyncExecutor

type SyncExecutor[T any] struct {
	Delegate delegate.Delegate[T]
}

SyncExecutor is the synchronous implementation of Executor. It executes tasks in sequence and no extra goroutines are used.

func (SyncExecutor[T]) ExecuteAll

func (s SyncExecutor[T]) ExecuteAll(ctx context.Context, args []T) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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