feat: add durable result journal and subscription delivery core
This commit is contained in:
38
platform/model/event_stream.go
Normal file
38
platform/model/event_stream.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
core "git.yuntuo.hk/k2safe/orbit/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
// EventStream 表示命名空间结果流;独立锁行避免升级认证身份共享锁。
|
||||
// 对应 orbit_event_streams;序号分配必须与任务状态和结果日志同事务提交。
|
||||
type EventStream struct {
|
||||
// NamespaceID 结果流所属命名空间,也是序号分配锁的主键。
|
||||
NamespaceID core.ID `db:"namespace_id"`
|
||||
// LastSequence 已分配序号,从1开始;回滚不消耗序号,0表示尚无结果。
|
||||
LastSequence uint64 `db:"last_sequence"`
|
||||
// RetainedFromSequence 最早保留序号;首版不清理,固定为1,防止以后静默跨过缺失历史。
|
||||
RetainedFromSequence uint64 `db:"retained_from_sequence"`
|
||||
// CreatedAt 结果流创建时间,统一UTC,精度微秒。
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
// UpdatedAt 最后分配序号时间,不能代替结果序号。
|
||||
UpdatedAt time.Time `db:"updated_at"`
|
||||
}
|
||||
|
||||
func (EventStream) TableName() string { return "orbit_event_streams" }
|
||||
|
||||
// ResultEvent 表示从迁移13启用的不可变任务结果快照;不补造历史任务事件。
|
||||
// 对应 orbit_result_events;Record.ID 与来源 Event.ID 相同,关联由事务校验。
|
||||
type ResultEvent struct {
|
||||
// Record 包含所属命名空间、来源事件标识、固定版本1及UTC时间。
|
||||
core.Record
|
||||
// Sequence 命名空间内提交有序的结果序号,首个为1。
|
||||
Sequence uint64 `db:"sequence"`
|
||||
// QueueID 来源任务队列,订阅必须具备该队列的消费权限。
|
||||
QueueID core.ID `db:"queue_id"`
|
||||
// Snapshot 版本化结果快照JSON,保留数值精度,不包含任务输入或租约秘密。
|
||||
Snapshot core.JSON `db:"snapshot"`
|
||||
}
|
||||
|
||||
func (ResultEvent) TableName() string { return "orbit_result_events" }
|
||||
Reference in New Issue
Block a user