Files
lingniu-vehicle-ingest/DECISIONS.md
lingniu 22468e78b4
Some checks failed
ci/woodpecker/manual/woodpecker Pipeline was canceled
chore: wire split apps deployment config
2026-06-24 14:38:59 +08:00

66 lines
3.3 KiB
Markdown
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.
# 架构决策记录ADR 汇总)
> 本文件记录 lingniu-vehicle-ingest v2 的关键架构决策,后续每次重大调整追加条目(不删除旧条目)。
## ADR-001 MQ 选型Kafka
- **Status**: Accepted
- **Context**: 需要高吞吐、严格单车有序、成熟生态
- **Decision**: 使用 Kafka分区 key = VIN
- **Consequences**: 下游消费者需使用消费组 + 分区内顺序消费;不使用 RocketMQ 的事务/顺序特性
## ADR-002 线上消息格式Protobuf
- **Status**: Accepted
- **Context**: 需要向前兼容、体积小、性能好
- **Decision**: 线上用 Protobuf调试/诊断保留 JSON 序列化能力
- **Consequences**: 需维护 `.proto` schema`ingest-api` 模块负责生成 Java stub
## ADR-003 command-gateway 独立模块
- **Status**: Accepted
- **Context**: 下行命令链路不应与接入进程耦合
- **Decision**: 拆出独立 `command-gateway` 模块,复用 `session-core`;本次重构同步交付
- **Consequences**: HTTP 对外接口(原 JT808Controller / JT1078Controller迁移到此模块
## ADR-004 信达 Push保留模块但彻底重写
- **Status**: Accepted
- **Context**: 旧实现硬编码凭证、无重连、0300/0401 空实现
- **Decision**:
1. 新模块 `inbound-xinda-push` 隔离第三方库 `gps-push-client`
2. 配置外置yml + env
3. 自动重连 + Resilience4j 熔断
4. 0200/0300/0401 **仅做协议解析**,转换为 `VehicleEvent` 后直接投 Kafka
5. **业务处理全部下沉到下游消费者**,本服务不再实现报警/透传业务逻辑
- **Consequences**: 旧代码 messageReceived 里的 TODO 不再回到本仓库;需要协调下游消费者团队认领
## ADR-005 JT1078 / JSATL12 进第一批
- **Status**: Accepted
- **Decision**: 第一批迁移即覆盖 JT1078 信令 + JSATL12 报警附件上传
- **Consequences**: Phase 2 工期相应拉长JSATL12 需要对象存储后端(本地 / S3 / OSS
## ADR-006 部署形态GB32960 三应用拆分
- **Status**: Superseded
- **Context**: 原 `bootstrap-all` 一体化启动已被 GB32960 拆分部署替代
- **Decision**: 生产默认部署 `gb32960-ingest-app``vehicle-history-app``vehicle-analytics-app` 三个应用;旧 `bootstrap-all` 模块删除
- **Consequences**: CI/CD 分别构建三个镜像;协议接入、历史查询、统计消费可以独立发布和回滚
## ADR-007 Java 25 + 虚拟线程 + Disruptor
- **Status**: Accepted
- **Decision**:
- Netty EventLoop 只做解码与 RingBuffer 投递,严禁阻塞
- 业务 Handler 走虚拟线程(`Thread.ofVirtual()`
- 协议间背压通过 Disruptor RingBuffer 表达
- 禁用 `synchronized`,使用 `ReentrantLock` 避免虚拟线程 pinning
- **Consequences**: 需开启 `jdk.VirtualThreadPinned` JFR 监控
## ADR-008 本服务不写业务库
- **Status**: Accepted
- **Decision**: 所有业务表vehicle_data_actual / history / travel / gps_data 等)不再由本服务写入
- **Consequences**: 需要新建消费服务 `vehicle-analytics-service` 承接;迁移期采用双跑对账
## ADR-009 构建工具Maven
- **Status**: Accepted
- **Decision**: 沿用 Maven统一 BOM 管理版本Spotless 格式化ArchUnit 守护分层
## ADR-010 框架Spring Boot 3.4
- **Status**: Accepted
- **Decision**: Spring Boot 3.4.x支持 JDK 25AutoConfiguration 用于按需启停