Versions in this module Expand all Collapse all v0 v0.0.2 Oct 5, 2022 Changes in this version type Task + ResultOrDefault func(interface{}) interface{} v0.0.1 Aug 25, 2022 Changes in this version + var ErrBatchProcessorNotActive = errors.New("batch processor has already shut down") + var ErrCancelled = errors.New("task cancelled") + func CancelAll(tasks []Task) + func CancelAllST(tasks []SilentTask) + func DoJitter(doFn func(), maxJitterDurationInMilliseconds int) int + func ForkJoin(ctx context.Context, tasks []Task) + func ForkJoinST(ctx context.Context, tasks []SilentTask) + func WaitAll(tasks []Task) + func WaitAllST(tasks []SilentTask) + type Batcher interface + Append func(payload interface{}) SilentTask + Process func(ctx context.Context) + Shutdown func() + Size func() int + func NewBatcher(processFn func([]interface{}) error, options ...BatcherOption) Batcher + type BatcherOption func(*batcherConfigs) + func WithAutoProcessInterval(autoProcessIntervalInMilliseconds time.Duration) BatcherOption + func WithAutoProcessSize(autoProcessSize int) BatcherOption + func WithShutdownGraceDuration(shutdownDurationInMilliseconds time.Duration) BatcherOption + type SilentTask interface + Cancel func() + Duration func() time.Duration + Error func() error + Execute func(ctx context.Context) SilentTask + ExecuteSync func(ctx context.Context) SilentTask + State func() State + Wait func() + func AddJitterST(t SilentTask, maxJitterDurationInMilliseconds int) SilentTask + func ContinueInSilence(currentTask SilentTask, nextAction func(context.Context, error) error) SilentTask + func ContinueWithNoResult(currentTask Task, nextAction func(context.Context, interface{}, error) error) SilentTask + func InvokeInSilence(ctx context.Context, action SilentWork) SilentTask + func NewSilentTask(action SilentWork) SilentTask + func NewSilentTasks(actions ...SilentWork) []SilentTask + func Repeat(ctx context.Context, interval time.Duration, action SilentWork) SilentTask + func Spread(ctx context.Context, tasks []Task, within time.Duration) SilentTask + func Throttle(ctx context.Context, tasks []Task, rateLimit int, every time.Duration) SilentTask + type SilentWork func(context.Context) error + type State byte + const IsCancelled + const IsCompleted + const IsCreated + const IsRunning + type Task interface + Outcome func() (interface{}, error) + Run func(ctx context.Context) Task + RunSync func(ctx context.Context) Task + func AddJitterT(t Task, maxJitterDurationInMilliseconds int) Task + func Completed(result interface{}, err error) Task + func ContinueWith(currentTask Task, ...) Task + func ContinueWithResult(currentTask SilentTask, ...) Task + func Invoke(ctx context.Context, action Work) Task + func NewTask(action Work) Task + func NewTasks(actions ...Work) []Task + type Work func(context.Context) (interface{}, error)