Documentation
¶
Overview ¶
Package feedback 提供 Message Feedback 接缝(Storage Domain sidecar + 稳定 fail 分类)。
对齐上游:packages/feedback/feedback(S09)
设计要点:
- 每个 (sessionId, messageId) 一条 Feedback 记录:rating/note/version(CAS)/createdAt/updatedAt;
- 复用 M45 storage.Domain[T] 的 CAS 版本(Put 带 expectedVersion,冲突报 VERSION_CONFLICT);
- 稳定错误分类:VERSION_CONFLICT / SESSION_NOT_FOUND / NOT_FOUND;
- list/put/delete。
validate.go 复刻官方 message-feedback 的值约束:评分只接受 thumbs up/down 两值 (0 表示未评分,不作为有效反馈落库);note 若提供则必须含非空白字符。
Index ¶
- Variables
- func ValidateNote(note string) error
- func ValidateRating(r Rating) error
- type FailCode
- type FailError
- type Feedback
- type Rating
- type Store
- func (s *Store) Delete(ctx context.Context, session brand.SessionID, messageID string) error
- func (s *Store) Get(ctx context.Context, session brand.SessionID, messageID string) (*Feedback, error)
- func (s *Store) List(ctx context.Context, session brand.SessionID) ([]Feedback, error)
- func (s *Store) Put(ctx context.Context, session brand.SessionID, messageID string, rating Rating, ...) (uint64, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmptyNote = errors.New("feedback: note must contain a non-whitespace character")
ErrEmptyNote note 提供了但全为空白。
View Source
var ErrInvalidRating = errors.New("feedback: rating must be thumbs up or down")
ErrInvalidRating 评分不是有效两值之一。
Functions ¶
func ValidateNote ¶
ValidateNote note 非空时要求含非空白字符;空串视为"不提供 note",合法。
func ValidateRating ¶
ValidateRating 校验评分只取 ThumbsUp/ThumbsDown。
Types ¶
type Feedback ¶
type Feedback struct {
// SessionID 所属会话 id。
SessionID brand.SessionID `json:"sessionId"`
// MessageID 消息标识。
MessageID string `json:"messageId"`
// Rating 评分(-1/0/1)。
Rating Rating `json:"rating"`
// Note 备注。
Note string `json:"note,omitempty"`
// Version CAS 版本(写时自增)。
Version uint64 `json:"version"`
// CreatedAt 创建时间。
CreatedAt time.Time `json:"createdAt"`
// UpdatedAt 最后更新时间。
UpdatedAt time.Time `json:"updatedAt"`
}
Feedback 是一条消息反馈。
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store 是 Message Feedback 存储。
func (*Store) Get ¶
func (s *Store) Get(ctx context.Context, session brand.SessionID, messageID string) (*Feedback, error)
Get 读取一条反馈;不存在 → NOT_FOUND。
Click to show internal directories.
Click to hide internal directories.