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 ¶
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