Documentation
¶
Index ¶
- Constants
- type DelayWheel
- func (de *DelayWheel) AfterExecute(d time.Duration, executor Executor) (taskId uint64, err error)
- func (de *DelayWheel) AfterFunc(d time.Duration, f func(task *TaskCtx)) (taskId uint64, err error)
- func (de *DelayWheel) CancelTask(taskID uint64)
- func (de *DelayWheel) PendingChan() <-chan func()
- func (de *DelayWheel) ScheduleExecute(d time.Duration, executor Executor) (taskId uint64, err error)
- func (de *DelayWheel) ScheduleFunc(d time.Duration, f func(ctx *TaskCtx)) (taskId uint64, err error)
- func (de *DelayWheel) Start()
- func (de *DelayWheel) Stop(stopFunc StopFunc) error
- type Executor
- type LogLevel
- type Logger
- type Option
- type StopCtx
- type StopFunc
- type Task
- type TaskCtx
Constants ¶
const ( STATE_TERMINATED wheelState = iota STATE_READY STATE_SHUTTING_DOWN )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DelayWheel ¶
type DelayWheel struct {
// contains filtered or unexported fields
}
func (*DelayWheel) AfterExecute ¶
Submit a delayed execution of a executor.
func (*DelayWheel) CancelTask ¶
func (de *DelayWheel) CancelTask(taskID uint64)
Cancel a task by TaskID
func (*DelayWheel) PendingChan ¶
func (de *DelayWheel) PendingChan() <-chan func()
Acquire the channel for pending running tasks
func (*DelayWheel) ScheduleExecute ¶
func (de *DelayWheel) ScheduleExecute(d time.Duration, executor Executor) (taskId uint64, err error)
Schedule a delayed execution of a executor with a time interval.
func (*DelayWheel) ScheduleFunc ¶
func (de *DelayWheel) ScheduleFunc(d time.Duration, f func(ctx *TaskCtx)) (taskId uint64, err error)
Schedule a delayed execution of a function with a time interval.
func (*DelayWheel) Stop ¶
func (de *DelayWheel) Stop(stopFunc StopFunc) error
Send a stop signal to delaywheel
type Executor ¶
type Executor interface {
Execute(taskCtx *TaskCtx)
}
Executor contains an Execute() method, > where TaskCtx is passed in to obtain the relevant parameters of the current task.
type Option ¶
type Option func(*DelayWheel)
func WithAutoRun ¶
func WithAutoRun() Option
WithAutoRun enables the automatic execution of tasks when they are due. When enabled, tasks will be executed in their own goroutines as soon as they are scheduled.
func WithCurTaskID ¶
WithCurTaskID sets the initial task ID for the DelayWheel. This can be used to start the task IDs from a specific number.
func WithLogLevel ¶
WithLogLevel sets the logging level for the DelayWheel. This controls the verbosity of the logs produced by the DelayWheel, allowing for finer control over what is logged.
func WithLogger ¶
WithLogger sets the logger to be used by the DelayWheel. This allows for custom logging implementations to be integrated into the DelayWheel, facilitating logging of internal events according to the user's preferences.
func WithPendingBufferSize ¶
WithPendingBufferSize sets the size of the buffer for the channel that holds pending tasks. This can be used to control the maximum number of tasks that can be held in the queue before being processed, which can help in managing memory usage and controlling how tasks are batched for execution.
type StopCtx ¶
type StopCtx struct {
// contains filtered or unexported fields
}
func (*StopCtx) GetAllTask ¶
func (*StopCtx) WaitForDone ¶
type Task ¶
type Task struct {
// contains filtered or unexported fields
}
func (*Task) Execute ¶
func (dt *Task) Execute()
Execute the task; Notice: The task will self-recycle and clear relevant data after execution.
func (*Task) IsCanceled ¶ added in v1.0.2
type TaskCtx ¶
type TaskCtx struct {
// contains filtered or unexported fields
}