feat(ingress): 实现 JDBC 信箱轮询、入站持久化与对拍测试 (U05)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.gzzn.omms.msgexchange.processing
|
||||
|
||||
import com.gzzn.omms.msgexchange.domain.DecodedMessage
|
||||
import com.gzzn.omms.msgexchange.domain.Decision
|
||||
import com.gzzn.omms.msgexchange.domain.MsgKind
|
||||
|
||||
/**
|
||||
* ACMA-8 流程 2:Handler = 纯函数(状态与报文进,Decision 出,不碰 Redis/Kafka)。
|
||||
* 32 个 Handler(flop 29 + schd 3)翻译属阶段 2/3,逐条对照 ACMA-4 基线与兼容矩阵 KEEP/FIX。
|
||||
*/
|
||||
interface Handler {
|
||||
val kind: MsgKind
|
||||
|
||||
/** 在线状态以只读快照传入(阶段 A 读 Redis 权威、阶段 B 读 FLIGHT_STATE,由调用方装配)。 */
|
||||
fun decide(flightView: Map<String, String>, msg: DecodedMessage): Decision
|
||||
}
|
||||
|
||||
/**
|
||||
* sealed 穷尽分派(ACMA-6 选型:取代 legacy 反射 get{TYPE}())。
|
||||
*/
|
||||
class HandlerRegistry(handlers: List<Handler>) {
|
||||
private val byKind: Map<String, Handler> = handlers.associateBy { keyOf(it.kind) }
|
||||
|
||||
fun dispatcherFor(msg: DecodedMessage): Handler? = byKind[keyOf(msg.kind)]
|
||||
|
||||
companion object {
|
||||
fun keyOf(kind: MsgKind): String = when (kind) {
|
||||
is MsgKind.Schd -> "SCHD-${kind.subtype.name}"
|
||||
is MsgKind.Flop -> "FLOP-${kind.subtype}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(阶段2/3): 注册 3+29 Handler;本阶段仅含骨架(阶段 2 最小纵向链路先做 1 SCHD(DNLD) + 1 FLOP)。
|
||||
Reference in New Issue
Block a user