Documentation
¶
Index ¶
- func GoSafely(f func() error) <-chan error
- func Parallel[In any, Out any](items []In, worker func(arg In, index int) ([]Out, error)) ([]Out, error)
- func ProcessInWorkQueue[TIn, TOut any](in []TIn, workerFunc func(TIn) ([]TOut, error), numWorkers int, bufferSize int, ...) ([]TOut, error)
- func RunTasks[T any](tasks ...*Task[T]) ([]T, error)
- func StartJobs(jobs []BackgroundJob)
- func WaitGroup(copies int, worker func() error) error
- type BackgroundJob
- type ErrorCallback
- type Handler
- type PanicError
- type Partitionable
- type RetryPolicy
- type Task
- type TaskResult
- type WorkItem
- type WorkQueue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoSafely ¶
GoSafely executes the given function in a goroutine that will never panic. If the given function panics, GoSafely will recover and return a special error (PanicError)
func ProcessInWorkQueue ¶
func StartJobs ¶
func StartJobs(jobs []BackgroundJob)
Types ¶
type BackgroundJob ¶
type ErrorCallback ¶
type PanicError ¶
type PanicError struct {
// contains filtered or unexported fields
}
func (*PanicError) Error ¶
func (p *PanicError) Error() string
func (*PanicError) Stack ¶
func (p *PanicError) Stack() string
type Partitionable ¶
type Partitionable interface {
PartitionKey() string
}
Partitionable is an optional interface that work items can implement to provide partition keys for ordered processing within partitions. If a type implements this interface, items with the same partition key will always be processed by the same worker in FIFO order.
type RetryPolicy ¶
type RetryPolicy int32
const RetryPolicyAfterDuration RetryPolicy = 1
const RetryPolicyImmediately RetryPolicy = 2
const RetryPolicyNever RetryPolicy = 0
type TaskResult ¶
type WorkQueue ¶
type WorkQueue[T any] struct { StopOnError bool RetryPolicy RetryPolicy RetryAfterDuration time.Duration MaxRetries int ErrorCallback ErrorCallback[T] // Partitioning support (optional) // PartitionFunc is an optional function to extract partition keys from items. // When set (or when items implement Partitionable), items with the same // partition key will be processed by the same worker in FIFO order. PartitionFunc func(T) string // contains filtered or unexported fields }
func NewWorkQueue ¶
func (*WorkQueue[T]) AwaitCompletion ¶
func (q *WorkQueue[T]) AwaitCompletion()
Click to show internal directories.
Click to hide internal directories.