Compare commits

..

No commits in common. "main" and "v1.5.4" have entirely different histories.
main ... v1.5.4

5 changed files with 9 additions and 14 deletions

View File

@ -1,8 +1,5 @@
# Changelog
## v1.5.5 - 2026-06-22
- **新增**: `Config.SuppressSuccessLog` 字段,设为 true 时调度器跳过 success 日志,由任务函数自行按处理量汇报,避免空轮询日志噪音。
## v1.5.4 - 2026-06-21
- **依赖更新**: 升级依赖 `jsmod``v1.5.3``cast``v1.5.3``rand``v1.5.3``encoding``v1.5.4``shell``v1.5.3``safe``v1.5.2``id``v1.5.4``file``v1.5.5``config``v1.5.3``log``v1.5.8`

View File

@ -33,9 +33,8 @@ task.Add("Report", "@every 1m", func(ctx context.Context) error {
// ...
return nil
}, task.Config{
Policy: task.PolicySkip, // 如果上次还没跑完,跳过本次
Timeout: 5 * time.Second, // 单次执行超时
SuppressSuccessLog: true, // 抑制默认 success 日志,由任务自行汇报
Policy: task.PolicySkip, // 如果上次还没跑完,跳过本次
Timeout: 5 * time.Second, // 单次执行超时
})
```

View File

@ -1,7 +1,7 @@
# Test Report
## Environment
- **Date**: 2026-06-22
- **Date**: 2026-06-21
- **Go Version**: go 1.25.0
- **OS**: darwin/amd64
@ -19,9 +19,9 @@
## Benchmarks
| Benchmark | Iterations | ns/op |
|-----------|------------|-------|
| BenchmarkTaskRegistration | 3664093 | 318.1 |
| BenchmarkTaskExecutionOverhead/Get | 52381898 | 26.07 |
| BenchmarkTaskExecutionOverhead/List | 10123669 | 116.2 |
| BenchmarkTaskRegistration | 4059084 | 294.0 |
| BenchmarkTaskExecutionOverhead/Get | 51555876 | 19.81 |
| BenchmarkTaskExecutionOverhead/List | 9835569 | 106.5 |
## Details

View File

@ -222,7 +222,7 @@ func (s *Scheduler) runTask(name string) {
if err != nil {
log.DefaultLogger.Error("task failed", "name", name, "err", err, "duration", duration.String())
} else if !t.Config.SuppressSuccessLog {
} else {
log.DefaultLogger.Info("task success", "name", name, "duration", duration.String())
}
}

View File

@ -24,9 +24,8 @@ const (
// Config 任务配置
type Config struct {
Policy Policy `json:"policy"`
Timeout time.Duration `json:"timeout"`
SuppressSuccessLog bool `json:"suppressSuccessLog"`
Policy Policy `json:"policy"`
Timeout time.Duration `json:"timeout"`
}
// WithPolicy 创建指定策略的配置