Documentation ¶
Index ¶
- Variables
- type StartFn
- type StopFn
- type Task
- type TaskHandler
- type Tasker
- func (t *Tasker) Add(ctx context.Context, f TaskHandler, p ...interface{})
- func (t *Tasker) AddWait(ctx context.Context, f TaskHandler, p ...interface{}) error
- func (t *Tasker) Init(opts ...TaskerOption)
- func (t *Tasker) IsRunning() bool
- func (t *Tasker) ResetTimer()
- func (t *Tasker) Run(ctx context.Context) error
- func (t *Tasker) Stop()
- type TaskerOption
- func WithChannelBufferSize(sz int) TaskerOption
- func WithExecuteTimeout(d time.Duration) TaskerOption
- func WithStartFns(f ...StartFn) TaskerOption
- func WithStopFns(f ...StopFn) TaskerOption
- func WithTimeout(d time.Duration) TaskerOption
- func WithUpdateFn(f UpdateFn) TaskerOption
- func WithUpdateInterval(d time.Duration) TaskerOption
- type TaskerOptions
- type UpdateFn
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TaskDefaultChannelSize = 64 // task channel buffer size TaskDefaultExecuteTimeout = time.Hour * 24 * 30 * 12 // execute timeout TaskDefaultTimeout = time.Second * 10 // default timeout TaskDefaultUpdateInterval = time.Second // update interval ErrTimeout = errors.New("time out") ErrTaskFailed = errors.New("task failed") )
Functions ¶
This section is empty.
Types ¶
type TaskHandler ¶
type Tasker ¶
type Tasker struct {
// contains filtered or unexported fields
}
func (*Tasker) AddWait ¶ added in v1.0.6
func (t *Tasker) AddWait(ctx context.Context, f TaskHandler, p ...interface{}) error
func (*Tasker) Init ¶
func (t *Tasker) Init(opts ...TaskerOption)
func (*Tasker) ResetTimer ¶
func (t *Tasker) ResetTimer()
type TaskerOption ¶
type TaskerOption func(*TaskerOptions)
func WithChannelBufferSize ¶ added in v1.1.4
func WithChannelBufferSize(sz int) TaskerOption
func WithExecuteTimeout ¶ added in v1.1.8
func WithExecuteTimeout(d time.Duration) TaskerOption
func WithStartFns ¶ added in v1.0.3
func WithStartFns(f ...StartFn) TaskerOption
func WithStopFns ¶ added in v1.1.1
func WithStopFns(f ...StopFn) TaskerOption
func WithTimeout ¶
func WithTimeout(d time.Duration) TaskerOption
func WithUpdateFn ¶ added in v1.0.2
func WithUpdateFn(f UpdateFn) TaskerOption
func WithUpdateInterval ¶ added in v1.1.7
func WithUpdateInterval(d time.Duration) TaskerOption
type TaskerOptions ¶
type TaskerOptions struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.