Files
orbit/platform/model/idempotency_key.go

33 lines
1.4 KiB
Go
Raw Permalink 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"
)
// IdempotencyKey 表示请求幂等记录,关联语义摘要与首次受理响应。
// 对应表 orbit_idempotency_keys;这是服务端持久化模型,不直接作为 API 响应。
type IdempotencyKey struct {
// Record 包含命名空间、记录标识、并发版本和 UTC 时间。
core.Record
// Operation 稳定操作类型,用于区分不同接口的幂等作用域。
Operation string `db:"operation"`
// ScopeKey 资源作用域标识;空字符串表示当前操作的默认作用域。
ScopeKey string `db:"scope_key"`
// KeyDigest 稳定幂等键或资源键的 SHA-256 摘要。
KeyDigest core.Digest `db:"key_digest"`
// RequestDigest 规范化请求语义的 SHA-256 摘要,用于识别同键不同内容。
RequestDigest core.Digest `db:"request_digest"`
// ResourceKind 关联资源类型;多态关联需要服务层额外校验。
ResourceKind string `db:"resource_kind"`
// ResourceID 关联资源标识,不能单独作为访问授权依据。
ResourceID core.ID `db:"resource_id"`
// Response 首次可靠提交后的响应 JSON,供重复请求补取确认。
Response core.JSON `db:"response"`
// ExpiresAt 幂等保留截止时间,不应短于约定的重发与恢复窗口。
ExpiresAt time.Time `db:"expires_at"`
}
func (IdempotencyKey) TableName() string { return "orbit_idempotency_keys" }