Version: 0.9.68.dev.260504
后端: 1. 阶段 3 notification 服务边界落地,新增 `cmd/notification`、`services/notification`、`gateway/notification`、`shared/contracts/notification` 和 notification port,按 userauth 同款最小手搓 zrpc 样板收口 2. notification outbox consumer、relay 和 retry loop 迁入独立服务入口,处理 `notification.feishu.requested`,gateway 改为通过 zrpc client 调用 notification 3. 清退旧单体 notification DAO/model/service/provider/runner 和 `service/events/notification_feishu.go`,旧实现不再作为活跃编译路径 4. 修复 outbox 路由归属、dispatch 启动扫描、Kafka topic 探测/投递超时、sending 租约恢复、毒消息 MarkDead 错误回传和 RPC timeout 边界 5. 同步调整 active-scheduler 触发通知事件、核心 outbox handler、MySQL 迁移边界和 notification 配置 文档: 1. 更新微服务迁移计划,将阶段 3 notification 标记为已完成,并明确下一阶段从 active-scheduler 开始
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
const (
|
||||
NotificationFeishuRequestedEventType = "notification.feishu.requested"
|
||||
NotificationFeishuRequestedEventVersion = "1"
|
||||
// DefaultFeishuNotificationDedupeWindow 是 notification 第一版固定的 30 分钟去重窗口。
|
||||
DefaultFeishuNotificationDedupeWindow = 30 * time.Minute
|
||||
)
|
||||
|
||||
// FeishuNotificationRequestedPayload 是飞书通知请求事件载荷。
|
||||
@@ -80,3 +82,20 @@ func (p FeishuNotificationRequestedPayload) MessageKey() string {
|
||||
func (p FeishuNotificationRequestedPayload) AggregateID() string {
|
||||
return strings.TrimSpace(p.PreviewID)
|
||||
}
|
||||
|
||||
// BuildFeishuNotificationDedupeKey 构造“user_id + trigger_type + time_window”去重键。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. 供事件发布方在生成 `notification.feishu.requested` payload 时复用;
|
||||
// 2. 只负责把固定窗口归一成稳定 key,不负责落 notification_records;
|
||||
// 3. requestedAt 为空或非法时直接返回空字符串,让上游显式感知入参不完整。
|
||||
func BuildFeishuNotificationDedupeKey(userID int, triggerType string, requestedAt time.Time, window time.Duration) string {
|
||||
if window <= 0 {
|
||||
window = DefaultFeishuNotificationDedupeWindow
|
||||
}
|
||||
if userID <= 0 || strings.TrimSpace(triggerType) == "" || requestedAt.IsZero() {
|
||||
return ""
|
||||
}
|
||||
windowStart := requestedAt.Truncate(window)
|
||||
return strconv.Itoa(userID) + ":" + strings.TrimSpace(triggerType) + ":" + windowStart.Format(time.RFC3339)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user