Files
smartmate/backend/infra/kafka/envelope.go
Losita a6c1e5d077 Version: 0.9.64.dev.260503
后端:
1. 服务级 outbox 基础设施全量落地——新增 service route / service catalog / route registry,重构 outbox engine、repository、event bus 和 model,按 `event_type -> service -> table/topic/group` 统一写入与投递,保留 `agent` 兼容壳但不再依赖共享 outbox
2. Kafka 投递、消费与启动装配同步切换——更新 kafka config、consumer、envelope,接入服务级 topic 与 consumer group,并同步调整 mysql 初始化、start/main/router 装配,保证各服务 relay / consumer 独立装配
3. 业务事件处理器按服务归属重接新 bus——`active-scheduler` 触发链路,以及 `agent` / `memory` / `notification` / `task` 相关 outbox handler 统一切到新路由注册与服务目录,避免新流量回流共享表
4. 同步更新《微服务四步迁移与第二阶段并行开发计划》,把阶段 1 改成当前基线并补齐结构图、阶段快照、风险回退和多代理执行口径
2026-05-03 20:29:00 +08:00

29 lines
1.2 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 kafka
import "encoding/json"
// Envelope 是 outbox 投递到 Kafka 的统一协议包。
//
// 协议边界:
// 1. 这是总线协议,不包含具体业务字段;
// 2. 路由只依赖 event_type不再保留 biz_type 兼容字段;
// 3. payload 为原始业务 JSON由业务 handler 决定如何反序列化。
type Envelope struct {
// OutboxID 是 outbox 状态机主键,用于消费者回写 consumed/retry/dead。
OutboxID int64 `json:"outbox_id"`
// EventID 是事件唯一标识(当前默认回退为 outbox_id 字符串)。
EventID string `json:"event_id,omitempty"`
// EventType 是唯一路由键(例如 chat.history.persist.requested
EventType string `json:"event_type"`
// EventVersion 是事件版本号(默认 v1
EventVersion string `json:"event_version,omitempty"`
// ServiceName 是事件归属服务;空值通常表示旧兼容消息或全量模式。
ServiceName string `json:"service_name,omitempty"`
// AggregateID 是聚合主键(例如 conversation_id用于追踪同一业务对象事件流。
AggregateID string `json:"aggregate_id,omitempty"`
// Payload 是业务载荷 JSON。
Payload json.RawMessage `json:"payload"`
}