Files
smartmate/backend/notification/runner.go
Losita 0a014f7472 Version: 0.9.60.dev.260430
后端:
1.接入主动调度 worker 与飞书通知链路
- 新增 due job scanner 与 active_schedule.triggered workflow
- 接入 notification.feishu.requested handler、飞书 webhook provider 和用户通知配置接口
- 支持 notification_records 去重、重试、skipped/dead 状态流转
- 完成 api / worker / all 启动模式装配与主动调度验收记录
2.后续要做的就是补全从异常发生到给用户推送消息之间的逻辑缺口
2026-04-30 23:45:27 +08:00

45 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package notification
import (
"context"
"log"
"time"
)
// StartRetryLoop 启动 notification_records 重试扫描器。
//
// 说明:
// 1. 只在 worker/all 模式启动api 模式不启动;
// 2. provider 失败后的重试由本循环负责,避免通用 outbox 被外部服务慢失败拖住;
// 3. 每轮失败只写日志,下一轮继续扫描。
func (s *NotificationService) StartRetryLoop(ctx context.Context, every time.Duration, limit int) {
if s == nil {
return
}
if every <= 0 {
every = time.Minute
}
if limit <= 0 {
limit = 50
}
go func() {
ticker := time.NewTicker(every)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
result, err := s.RetryFeishuNotifications(ctx, time.Now(), limit)
if err != nil {
log.Printf("飞书通知重试扫描失败: err=%v", err)
continue
}
if result.Scanned > 0 {
log.Printf("飞书通知重试扫描完成: scanned=%d sent=%d failed=%d dead=%d skipped=%d", result.Scanned, result.Sent, result.Failed, result.Dead, result.Skipped)
}
}
}
}()
}