package transaction import ( "encoding/json" "time" ) // Transaction 是一次更新请求的服务端持久化快照。 type Transaction struct { ID string IdempotencyKey string Source string Service string Request json.RawMessage State State Version int64 CreatedAt time.Time UpdatedAt time.Time } // CreateRequest 包含创建事务所需的不可变请求信息。 type CreateRequest struct { ID string IdempotencyKey string Source string Service string Request json.RawMessage } // StepStatus 是外部步骤的持久化执行状态。 type StepStatus string const ( StepIntentRecorded StepStatus = "INTENT_RECORDED" StepSucceeded StepStatus = "SUCCEEDED" StepFailed StepStatus = "FAILED" ) // Step 记录一次外部副作用的意图和最终核对结果。 type Step struct { TransactionID string Key string Name string Status StepStatus Intent json.RawMessage Result json.RawMessage Error string CreatedAt time.Time UpdatedAt time.Time } // StepIntent 是执行外部操作前必须先持久化的内容。 type StepIntent struct { Key string Name string Intent json.RawMessage } // Event 是供查询和 WSS 断联恢复使用的顺序事件。 type Event struct { Sequence int64 TransactionID string StepKey string Kind string FromState State ToState State Message string CreatedAt time.Time }