Documentation ¶
Index ¶
- Variables
- func WithErrorHandler(handler ErrorHandler) _PoolExecutorOption
- func WithExecuteTimeout(ts time.Duration) _PoolExecutorOption
- func WithLogger(logger *slog.Logger) _PoolExecutorOption
- func WithMaxBlockingTasks(max int) _PoolExecutorOption
- func WithMaxConcurrent(concurrent int) _PoolExecutorOption
- func WithRejectionHandler(handler RejectionHandler) _PoolExecutorOption
- type CRONRule
- type Callable
- type CallableFunc
- type CallerRunsRejectionPolicy
- type CancelFunc
- type CatchFunction
- type DiscardErrorHandler
- type DiscardRejectionPolicy
- type ErrInvalidState
- type ErrPanic
- type ErrorHandler
- type ErrorHandlerFunc
- type Executor
- type ExecutorService
- type Future
- type FutureTask
- func (f *FutureTask[T]) Cancel() bool
- func (f *FutureTask[T]) Canceled() bool
- func (f *FutureTask[T]) Catch(catchFunc CatchFunction) Future[T]
- func (f *FutureTask[T]) Completed() bool
- func (f *FutureTask[T]) CompletedError() bool
- func (f *FutureTask[T]) Get(ctx context.Context) (T, error)
- func (f *FutureTask[T]) Run(ctx context.Context)
- func (f *FutureTask[T]) Then(thenFunc ThenFunction[T]) Future[T]
- type LogErrorHandler
- type NoopErrorHandler
- type NoopRejectionPolicy
- type PoolExecutor
- type PoolScheduleExecutor
- func (p *PoolScheduleExecutor) Schedule(r Runnable, delay time.Duration) (CancelFunc, error)
- func (p *PoolScheduleExecutor) ScheduleAtCronRate(r Runnable, rule CRONRule) (CancelFunc, error)
- func (p *PoolScheduleExecutor) ScheduleAtFixRate(r Runnable, period time.Duration) (CancelFunc, error)
- func (p *PoolScheduleExecutor) Shutdown(ctx context.Context) error
- type RejectionHandler
- type Runnable
- type RunnableFunc
- type ScheduledExecutor
- type ThenFunction
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRejectedExecution = errors.New("rejected execution") ErrShutdown = errors.New("shutdown") ErrInvalidCronExpr = errors.New("invalid corn expr") ErrInvalidCronTimezone = errors.New("invalid corn timezone") )
View Source
var (
ErrFutureCanceled = errors.New("future canceled")
)
Functions ¶
func WithErrorHandler ¶
func WithErrorHandler(handler ErrorHandler) _PoolExecutorOption
func WithExecuteTimeout ¶
func WithLogger ¶ added in v0.0.6
func WithMaxBlockingTasks ¶
func WithMaxBlockingTasks(max int) _PoolExecutorOption
func WithMaxConcurrent ¶
func WithMaxConcurrent(concurrent int) _PoolExecutorOption
func WithRejectionHandler ¶
func WithRejectionHandler(handler RejectionHandler) _PoolExecutorOption
Types ¶
type CallableFunc ¶
type CallerRunsRejectionPolicy ¶
type CallerRunsRejectionPolicy struct { }
func (CallerRunsRejectionPolicy) RejectExecution ¶
func (d CallerRunsRejectionPolicy) RejectExecution(runnable Runnable, e Executor) error
type CancelFunc ¶ added in v0.0.4
type CancelFunc = func()
type CatchFunction ¶
type CatchFunction func(err error)
type DiscardErrorHandler ¶
type DiscardErrorHandler struct { }
func (DiscardErrorHandler) CatchError ¶ added in v0.1.0
func (d DiscardErrorHandler) CatchError(runnable Runnable, e error)
type DiscardRejectionPolicy ¶
type DiscardRejectionPolicy struct { }
func (DiscardRejectionPolicy) RejectExecution ¶
func (d DiscardRejectionPolicy) RejectExecution(runnable Runnable, e Executor) error
type ErrInvalidState ¶
type ErrInvalidState struct {
// contains filtered or unexported fields
}
func (ErrInvalidState) Error ¶
func (e ErrInvalidState) Error() string
type ErrorHandler ¶ added in v0.1.0
type ErrorHandlerFunc ¶
func (ErrorHandlerFunc) CatchError ¶ added in v0.1.0
func (f ErrorHandlerFunc) CatchError(runnable Runnable, e error)
type Executor ¶
type Executor interface { // Execute execute a task in background // Will return ErrShutdown if shutdown already // Will return ErrRejectedExecution if task out of cap Execute(Runnable) error // Shutdown shutdown the executor // Will wait the queued task to be finish Shutdown(ctx context.Context) error }
func NewPoolExecutor ¶
func NewPoolExecutor(opts ..._PoolExecutorOption) Executor
type ExecutorService ¶
type ExecutorService[T any] interface { Executor // Submit execute a task with result async, and can get the task result via get Submit(callable Callable[T]) (Future[T], error) }
func NewPoolExecutorService ¶
func NewPoolExecutorService[T any](opts ..._PoolExecutorOption) ExecutorService[T]
type FutureTask ¶
type FutureTask[T any] struct { // contains filtered or unexported fields }
func NewFutureTask ¶
func NewFutureTask[T any](callable Callable[T]) *FutureTask[T]
func (*FutureTask[T]) Cancel ¶
func (f *FutureTask[T]) Cancel() bool
func (*FutureTask[T]) Canceled ¶
func (f *FutureTask[T]) Canceled() bool
func (*FutureTask[T]) Catch ¶
func (f *FutureTask[T]) Catch(catchFunc CatchFunction) Future[T]
func (*FutureTask[T]) Completed ¶
func (f *FutureTask[T]) Completed() bool
func (*FutureTask[T]) CompletedError ¶
func (f *FutureTask[T]) CompletedError() bool
func (*FutureTask[T]) Then ¶
func (f *FutureTask[T]) Then(thenFunc ThenFunction[T]) Future[T]
type LogErrorHandler ¶ added in v0.1.0
type LogErrorHandler struct { }
func (LogErrorHandler) CatchError ¶ added in v0.1.0
func (d LogErrorHandler) CatchError(runnable Runnable, e error)
type NoopErrorHandler ¶
type NoopErrorHandler struct { }
func (NoopErrorHandler) CatchError ¶ added in v0.1.0
func (d NoopErrorHandler) CatchError(runnable Runnable, e error)
type NoopRejectionPolicy ¶
type NoopRejectionPolicy struct { }
func (NoopRejectionPolicy) RejectExecution ¶
func (d NoopRejectionPolicy) RejectExecution(runnable Runnable, e Executor) error
type PoolExecutor ¶
type PoolExecutor[T any] struct { // contains filtered or unexported fields }
func (*PoolExecutor[T]) Execute ¶
func (p *PoolExecutor[T]) Execute(r Runnable) error
type PoolScheduleExecutor ¶ added in v0.0.4
type PoolScheduleExecutor struct { *PoolExecutor[any] // contains filtered or unexported fields }
func (*PoolScheduleExecutor) Schedule ¶ added in v0.0.4
func (p *PoolScheduleExecutor) Schedule(r Runnable, delay time.Duration) (CancelFunc, error)
func (*PoolScheduleExecutor) ScheduleAtCronRate ¶ added in v0.0.6
func (p *PoolScheduleExecutor) ScheduleAtCronRate(r Runnable, rule CRONRule) (CancelFunc, error)
func (*PoolScheduleExecutor) ScheduleAtFixRate ¶ added in v0.0.4
func (p *PoolScheduleExecutor) ScheduleAtFixRate(r Runnable, period time.Duration) (CancelFunc, error)
type RejectionHandler ¶
type RunnableFunc ¶
func (RunnableFunc) Run ¶
func (r RunnableFunc) Run(ctx context.Context)
type ScheduledExecutor ¶ added in v0.0.4
type ScheduledExecutor interface { Executor // Schedule run a one time task after delay duration Schedule(r Runnable, delay time.Duration) (CancelFunc, error) // ScheduleAtFixRate schedule a periodic task in fixed rate ScheduleAtFixRate(r Runnable, period time.Duration) (CancelFunc, error) // ScheduleAtCronRate schedule at periodic cron task ScheduleAtCronRate(r Runnable, rule CRONRule) (CancelFunc, error) }
func NewPoolScheduleExecutor ¶ added in v0.0.4
func NewPoolScheduleExecutor(opts ..._PoolExecutorOption) ScheduledExecutor
type ThenFunction ¶
type ThenFunction[T any] func(val T)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.