Files
orbit/platform/model/delivery.go

39 lines
1.7 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"
)
// Delivery 表示单个事件向一个订阅的可靠交付记录。
// 对应表 orbit_deliveries;这是服务端持久化模型,不直接作为 API 响应。
type Delivery struct {
// Record 包含命名空间、记录标识、并发版本和 UTC 时间。
core.Record
// SubscriptionID 目标订阅标识。
SubscriptionID core.ID `db:"subscription_id"`
// EventID 来源持久化事件标识,用于消费去重。
EventID core.ID `db:"event_id"`
// State 当前状态;只允许定义的状态转换并配合事务校验。
State DeliveryState `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"`
// Attempts 已产生的交付尝试次数,不等同于业务执行次数。
Attempts uint32 `db:"attempts"`
// AttemptBudget 累计允许发送次数;人工追加预算,不重置Attempts或LeaseEpoch。
AttemptBudget uint32 `db:"attempt_budget"`
// TokenDigest 最近交付秘密的摘要;首次发送前为空,确认后保留以验证重复确认。
TokenDigest *core.Digest `db:"token_digest"`
// AcknowledgedAt 接收方可靠处理后的确认时间;未确认时为空。
AcknowledgedAt *time.Time `db:"acknowledged_at"`
}
func (Delivery) TableName() string { return "orbit_deliveries" }