Files
orbit/weave/model/inbox_event.go

43 lines
2.1 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 model
import (
"time"
core "git.yuntuo.hk/k2safe/orbit/model"
)
// InboxEvent 表示Weave 内部事件消费记录,和流程推进一起确认消费。
// 对应表 weave_inbox;这是服务端持久化模型,不直接作为 API 响应。
type InboxEvent struct {
// Record 包含命名空间、记录标识、并发版本和 UTC 时间。
core.Record
// WorkflowID 所属流程实例标识。
WorkflowID core.ID `db:"workflow_id"`
// EventID 来源持久化事件标识,用于消费去重。
EventID core.ID `db:"event_id"`
// SourceTaskID 来源Pulse任务;只有迁移前未核实的历史记录可空,不能据此重新推进。
SourceTaskID *core.ID `db:"source_task_id"`
// SourceActivationID 事件发生时的激活身份,消费时需核对是否仍为当前激活;未核实历史可空。
SourceActivationID *core.ID `db:"source_activation_id"`
// SourceRevision 来源任务状态版本,大于零,同一任务版本只交付一次;未核实历史可空。
SourceRevision *uint64 `db:"source_revision"`
// Snapshot 当时的版本化结果JSON文本,独立于外部订阅日志和当前任务;未核实历史为空。
Snapshot core.JSON `db:"snapshot"`
// State 当前状态;只允许定义的状态转换并配合事务校验。
State InboxState `db:"state"`
// AvailableAt 最早可被领取或处理的时间,统一 UTC。
AvailableAt time.Time `db:"available_at"`
// LeaseOwner 租约持有者标识;未持有租约时为空。
LeaseOwner *core.ID `db:"lease_owner"`
// LeaseEpoch 递增的执行或消费代次,用于隔离旧授权。
LeaseEpoch uint64 `db:"lease_epoch"`
// LeaseUntil 内部消费租约截止时间;没有消费租约时为空。
LeaseUntil *time.Time `db:"lease_until"`
// ProcessedAt 内部事件完成消费的时间;尚未消费时为空。
ProcessedAt *time.Time `db:"processed_at"`
// ErrorCode 稳定错误分类,供恢复策略判断;不得写入敏感原始错误;可为空,表示尚未设置该关联或值。
ErrorCode *string `db:"error_code"`
}
func (InboxEvent) TableName() string { return "weave_inbox" }