Compare commits

...

1 Commits
v1.5.4 ... main

Author SHA1 Message Date
AI Engineer
d62d94d48c feat(task): Config 新增 SuppressSuccessLog 字段,支持抑制空轮询 success 日志(by AI)
Co-Authored-By: glm-5.1 <zai-org@claude-code-best.win>
2026-06-22 17:10:37 +08:00
5 changed files with 14 additions and 9 deletions

View File

@ -1,5 +1,8 @@
# Changelog # Changelog
## v1.5.5 - 2026-06-22
- **新增**: `Config.SuppressSuccessLog` 字段,设为 true 时调度器跳过 success 日志,由任务函数自行按处理量汇报,避免空轮询日志噪音。
## v1.5.4 - 2026-06-21 ## 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` - **依赖更新**: 升级依赖 `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

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

View File

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

View File

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

View File

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