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.后续要做的就是补全从异常发生到给用户推送消息之间的逻辑缺口
This commit is contained in:
44
backend/notification/runner.go
Normal file
44
backend/notification/runner.go
Normal file
@@ -0,0 +1,44 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user