29 lines
1.0 KiB
Kotlin
29 lines
1.0 KiB
Kotlin
package com.gzzn.omms.msgexchange.processing
|
||||
|
|
|
|||
|
|
import com.gzzn.omms.msgexchange.domain.ProcState
|
|||
|
|
import com.gzzn.omms.msgexchange.domain.ProcStatus
|
|||
|
|
import com.gzzn.omms.msgexchange.infra.persistence.PipelineLockRepository
|
|||
|
|
import com.gzzn.omms.msgexchange.infra.persistence.PipelineTransactionManager
|
|||
|
|
import com.gzzn.omms.msgexchange.infra.persistence.ProcStateRepository
|
|||
|
|
import jakarta.inject.Singleton
|
|||
|
|
import java.time.Clock
|
|||
|
|
|
|||
|
|
/** 静态参考数据单事务提交:落库 + 终态 + 回填意图(无 Redis / MSG_EVENT,`US-13`)。 */
|
|||
|
|
@Singleton
|
|||
|
|
class RefDataCommit(
|
|||
|
|
private val txManager: PipelineTransactionManager,
|
|||
|
|
private val lock: PipelineLockRepository,
|
|||
|
|
private val procState: ProcStateRepository,
|
|||
|
|
private val clock: Clock,
|
|||
|
|
) {
|
|||
|
|
fun commit(head: ProcState, work: () -> Unit) {
|
|||
|
|
lock.holdAcrossTransactions {
|
|||
|
|
txManager.inTransaction {
|
|||
|
|
lock.lock()
|
|||
|
|
work()
|
|||
|
|
procState.markTerminal(head.msgId, ProcStatus.SUCCEEDED, now = clock.instant())
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|