feat: establish Orbit models, migrations and development baseline
This commit is contained in:
34
platform/model/delivery.go
Normal file
34
platform/model/delivery.go
Normal file
@@ -0,0 +1,34 @@
|
||||
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"`
|
||||
// AcknowledgedAt 接收方可靠处理后的确认时间;未确认时为空。
|
||||
AcknowledgedAt *time.Time `db:"acknowledged_at"`
|
||||
}
|
||||
|
||||
func (Delivery) TableName() string { return "orbit_deliveries" }
|
||||
Reference in New Issue
Block a user