Documentation
¶
Overview ¶
Package identity 是 Identity 领域模型的原型验证层(见 docs/plans/2026-07-16-Identity领域模型.md),不进正式代码。
Task 结构还没有 BusinessKey/ReplayOf 字段,原型把四概念记在层内的侧车 map 里, 包一层 taskgate 公共 API 跑真调度——验证的是模型语义,不是存储。 侧车用一把互斥锁模拟正式实现里"唯一约束 + 原子校验"的职责 (模型文档问题清单 #6),单进程内语义等价。
约定:走本层 Submit 的任务不要再传 taskgate.WithID(模型终态:ExecutionID 用户不可指定),ID 一律由 broker 生成 ulid。
Index ¶
- Variables
- type Layer
- func (l *Layer) History(key string) []string
- func (l *Layer) ReplayByID(ctx context.Context, execID string, opt ReplayOptions) (string, error)
- func (l *Layer) ReplayByKey(ctx context.Context, key string, opt ReplayOptions) (string, error)
- func (l *Layer) ReplayOf(execID string) (string, bool)
- func (l *Layer) Submit(ctx context.Context, taskType string, payload json.RawMessage, key string, ...) (string, error)
- type ReplayOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFinal Replay 目标还没到终态(前置条件①)。 ErrNotFinal = errors.New("identity: replay target not in final state") // ErrInFlight 该 BusinessKey 下还有非终态 execution(前置条件②,"≤1 在途"不变式)。 ErrInFlight = errors.New("identity: business key has an in-flight execution") // ErrAlreadyReplayed 目标已被重放过,链不分叉(前置条件③)。 ErrAlreadyReplayed = errors.New("identity: execution already replayed (chain must not fork)") // ErrCompletedNotAllowed 重放 completed 执行必须显式传 AllowCompleted(评审确认 #2)。 ErrCompletedNotAllowed = errors.New("identity: replaying a completed execution requires AllowCompleted") // ErrUnknownExecution 目标 execution 不存在于本层记录。 ErrUnknownExecution = errors.New("identity: unknown execution") // ErrUnknownKey 该 BusinessKey 不存在。 ErrUnknownKey = errors.New("identity: unknown business key") )
模型规则对应的错误。Submit 同键拒绝直接复用 taskgate.ErrTaskExists(契约 2 语义)。
Functions ¶
This section is empty.
Types ¶
type Layer ¶
type Layer struct {
// contains filtered or unexported fields
}
Layer Identity 原型层。所有侧车状态用一把锁保护, 模拟正式实现里后端原子完成的唯一性校验。
func (*Layer) ReplayByID ¶
ReplayByID 按 ExecutionID 重放。目标必须是其链的链尾(未被重放过)。
func (*Layer) ReplayByKey ¶
ReplayByKey 按 BusinessKey 重放,天然作用于链尾(最新 execution)。
type ReplayOptions ¶
type ReplayOptions struct {
AllowCompleted bool // 允许重放 completed 的执行,必须显式打开
Payload json.RawMessage // nil = 复制旧执行的 Payload(模型问题 #3 的倾向)
}
ReplayOptions Replay 的显式参数。
Click to show internal directories.
Click to hide internal directories.