Documentation ¶
Index ¶
- Variables
- func ScheduleTaskFunc(task func() error)
- func ScheduleTaskFuncWithContext(ctx context.Context, task func(ctx context.Context) error)
- type Callable
- type CallableCallback
- type Future
- type OnStopCallback
- type Permits
- type Runnable
- type RunnableCallback
- type RunnerOption
- type RunnerTask
- type Scheduler
- type SchedulerOption
- type TaskRunner
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSchedulerStopping = errors.New("scheduler is stopping") ErrSchedulerStopped = errors.New("scheduler is stopped") )
View Source
var (
ErrNoTasks = errors.New("no tasks in runner")
)
Functions ¶
func ScheduleTaskFunc ¶
func ScheduleTaskFunc(task func() error)
Types ¶
type CallableCallback ¶
type CallableCallback func(interface{}, error)
type OnStopCallback ¶
type OnStopCallback func()
type RunnableCallback ¶
type RunnableCallback func(error)
type RunnerOption ¶
type RunnerOption interface {
// contains filtered or unexported methods
}
func WithEagerFail ¶
func WithEagerFail(enable bool) RunnerOption
WithEagerFail is a fail fast switch useful when calling runner.RunAndWaitAll() The call will return on the first failure
func WithMaxParallelism ¶
func WithMaxParallelism(max int) RunnerOption
WithMaxParallelism sets the maximum parallelism for the runner; if max is less than 1, then no parallelism limit is set This is a concurrency rate-limiter for when the number of tasks can be high. At any point, there are at most `max` task (goroutines) running concurrently.
func WithRetryOptions ¶
func WithRetryOptions(options ...gotries.Option) RunnerOption
WithRetryOptions sets the default retry options for all the added tasks
func WithSequentialParallelism ¶
func WithSequentialParallelism() RunnerOption
WithSequentialParallelism is a syntactic sugar to WithMaxParallelism(1). Useful for executing multiple tasks serially
type RunnerTask ¶
type Scheduler ¶
type Scheduler interface { Schedule(ctx context.Context, runnable Runnable, delay time.Duration) Future ScheduleAtFixedRate(ctx context.Context, runnable Runnable, initialDelay, interval time.Duration) Future }
func DefaultScheduler ¶
func DefaultScheduler() Scheduler
func NewScheduler ¶
func NewScheduler(options ...SchedulerOption) Scheduler
type SchedulerOption ¶
type SchedulerOption interface {
// contains filtered or unexported methods
}
func WithSchedulerMaxPoolSize ¶
func WithSchedulerMaxPoolSize(max int) SchedulerOption
func WithSchedulerName ¶
func WithSchedulerName(name string) SchedulerOption
func WithSchedulerPoolSize ¶
func WithSchedulerPoolSize(size int) SchedulerOption
type TaskRunner ¶
type TaskRunner interface { AddTask(task RunnerTask, options ...gotries.Option) TaskRunner AddRunnableTask(runnable Runnable, options ...gotries.Option) TaskRunner AddCallableTask(callable Callable, options ...gotries.Option) TaskRunner RunAndWaitAll(ctx context.Context) ([]interface{}, error) RunAndWaitAny(ctx context.Context) (interface{}, error) }
func NewTaskRunner ¶
func NewTaskRunner(options ...RunnerOption) TaskRunner
Source Files ¶
Click to show internal directories.
Click to hide internal directories.