优化抖动幅度和日志双时间显示

- jitterDuration 抖动从 base/3 降至 base/10,避免过大的随机延迟
- 日志新增斗鱼双时间显示:本地时间后追加 (D斗鱼时间),前端蓝色高亮
- 时间校准后自动同步斗鱼偏移量到日志模块
This commit is contained in:
yml2213
2026-06-27 16:39:23 +08:00
parent 8029333613
commit 99885c1ddd
5 changed files with 42 additions and 7 deletions
+2 -2
View File
@@ -644,8 +644,7 @@ func jitterDuration(base time.Duration) time.Duration {
if base <= 0 {
return 0
}
// 加一点抖动,避免所有机器严格同频请求。
jitter := time.Duration(rand.Int63n(int64(base / 3)))
jitter := time.Duration(rand.Int63n(int64(base / 10)))
return base + jitter
}
@@ -858,6 +857,7 @@ func (s *Scheduler) calibrateDouyuTime(label string) types.TimeCalibration {
if err != nil {
logger.LogEvent("时间", "warn", "%s校准降级: %v", label, err)
}
logger.SetDouyuOffset(calibration.Offset)
logger.LogEvent("时间", "success", "%s校准完成: 斗鱼估算=%s 偏移=%dms 误差<=%dms RTT=%dms 采样=%d 来源=%s",
label,
calibration.EstimatedServerNow().In(constants.CST).Format("2006-01-02 15:04:05.000"),