Files
backend_v2/internal/model/ingest_nonce.go
toom1996 10d8a96e8c update
2026-09-07 00:04:01 +08:00

15 lines
610 B
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
// IngestNonce 爬虫上报的一次性随机串,用于防重放。
//
// 每次合法请求携带唯一 X-Nonce;后台先查库,若存在则拒绝(409 重放),
// 否则放行并写入。nonce 本身随机且一次性,空间可忽略;
// created_at 用于定期清理(如保留 7 天)以防表无限增长。
type IngestNonce struct {
Nonce string `gorm:"primaryKey;column:nonce;size:64" json:"nonce"`
CreatedAt uint32 `gorm:"column:created_at" json:"created_at"`
}
// TableName 指定 nonce 表名。
func (IngestNonce) TableName() string { return "ingest_nonces" }