Documentation
¶
Index ¶
- func InitializeDefaultLogHandler()
- func LoadConfig(cfg Config)
- func LogMessage(taskID uint, level LogLevel, message string)
- func SetLogHandler(handler LogHandler)
- type Config
- type Executor
- type GroupQueue
- type LogHandler
- type LogLevel
- type MutexManager
- type Option
- type PriorityQueue
- type Registry
- type ScheduledTask
- type TaskExecutionEntry
- type TaskFunc
- type TaskItem
- type TaskRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitializeDefaultLogHandler ¶
func InitializeDefaultLogHandler()
InitializeDefaultLogHandler 初始化默认日志处理器(输出到控制台)
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor 任务执行器
func NewExecutor ¶
func NewExecutor(ctx context.Context, registry *Registry, mutexMgr *MutexManager, workers int) *Executor
NewExecutor 创建新的 Executor
type GroupQueue ¶
type GroupQueue struct {
// contains filtered or unexported fields
}
GroupQueue 表示一个互斥组的任务队列
type LogHandler ¶
LogHandler 日志处理函数类型
type MutexManager ¶
type MutexManager struct {
// contains filtered or unexported fields
}
MutexManager 管理互斥组的锁和队列
func (*MutexManager) Enqueue ¶
func (m *MutexManager) Enqueue(group string, taskName string, execute func(), priority int)
Enqueue 将任务添加到互斥组队列
func (*MutexManager) Finish ¶
func (m *MutexManager) Finish(group string)
Finish 设置互斥组的运行状态为完成,并尝试执行下一个任务
type PriorityQueue ¶
type PriorityQueue []*TaskItem
PriorityQueue 实现 heap.Interface
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x interface{})
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry 任务注册表
type ScheduledTask ¶
type ScheduledTask struct { ID uint Name string IntervalSecs int MaxRunTimeSecs int IsActive bool LastRunTime *time.Time LastExecStatus string IsRunning bool MutexGroup string Dependencies []string Priority int // 新增字段,数值越大优先级越高 }
ScheduledTask 定时任务结构体
type TaskExecutionEntry ¶
type TaskExecutionEntry struct {
// contains filtered or unexported fields
}
TaskExecutionEntry 任务执行条目
type TaskItem ¶
type TaskItem struct {
// contains filtered or unexported fields
}
TaskItem 包含任务名称和优先级
type TaskRunner ¶
type TaskRunner struct {
// contains filtered or unexported fields
}
TaskRunner 定时任务运行器
func (*TaskRunner) RegisterTask ¶
func (tr *TaskRunner) RegisterTask(name string, fn TaskFunc, intervalSecs, maxRunTimeSecs int, mutexGroup string, dependencies []string, priority int) error
RegisterTask 注册一个任务
func (*TaskRunner) RunTaskNow ¶
func (tr *TaskRunner) RunTaskNow(name string, priority int) error
RunTaskNow 立即运行指定任务
func (*TaskRunner) SetLogHandler ¶
func (tr *TaskRunner) SetLogHandler(handler LogHandler)
SetLogHandler 允许开发者设置自定义日志处理器
Source Files
¶
Click to show internal directories.
Click to hide internal directories.