Documentation
¶
Index ¶
- func AsyncExecute[T any](ctx context.Context, fn func(ctx context.Context) (T, error)) <-chan AsyncResult[T]
- func BatchConcurrent[T, R any](ctx context.Context, concurrency int, slice []T, ...) ([]R, error)
- func ConExecute(ctx context.Context, limit int, timeout time.Duration, tasks ...Task) error
- func ConExecuteAll(ctx context.Context, limit int, tasks ...Task) (errs []error)
- func DoWithRetry(ctx context.Context, f func() error, maxAttempts int, backoff time.Duration) error
- func SeqExecute(ctx context.Context, tasks ...Task) error
- func SeqExecuteAll(ctx context.Context, tasks ...Task) (errs []error)
- type AsyncResult
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsyncExecute ¶
func AsyncExecute[T any](ctx context.Context, fn func(ctx context.Context) (T, error)) <-chan AsyncResult[T]
AsyncExecute executes function asynchronously.
func BatchConcurrent ¶
func BatchConcurrent[T, R any](ctx context.Context, concurrency int, slice []T, fn func(context.Context, T) (R, error)) ([]R, error)
BatchConcurrent batch execute function concurrently. The concurrency indicates how many fn are executing at the same time.
func ConExecute ¶ added in v0.0.62
ConExecute concurrently execute tasks with concurrent upper limit. If timeout is 0, there will be no timeout. If any one of tasks reports an error and the others are interrupted immediately.
func ConExecuteAll ¶ added in v0.0.62
ConExecuteAll concurrently executes all tasks with concurrent upper limit. If one of tasks reports an error, continue to execute the remaining tasks and return all errors occurred.
func DoWithRetry ¶
func SeqExecute ¶ added in v0.0.62
SeqExecute executes tasks sequentially. If an error is encountered, return immediately.
Types ¶
type AsyncResult ¶
AsyncResult is the result of the function executed asynchronously.