Documentation
¶
Overview ¶
Package feedback implements message feedback using Storage Domain sidecars and stable failure classes, matching feedback/feedback (S09). Each session/message pair has a rating, note, CAS version, and timestamps. List, put, and delete use M45 storage.Domain; failures are VERSION_CONFLICT, SESSION_NOT_FOUND, or NOT_FOUND.
Validation matches message-feedback upstream: only thumbs up/down are stored as valid ratings (zero means unrated). A supplied note must contain non-whitespace.
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 ¶
var ErrEmptyNote = errors.New("feedback: note must contain a non-whitespace character")
ErrEmptyNote indicates a supplied note containing only whitespace.
var ErrInvalidRating = errors.New("feedback: rating must be thumbs up or down")
ErrInvalidRating indicates a rating other than thumbs up or down.
Functions ¶
func ValidateNote ¶
ValidateNote requires non-whitespace for nonempty notes; empty means omitted.
func ValidateRating ¶
ValidateRating accepts only ThumbsUp and ThumbsDown.
Types ¶
type Feedback ¶
type Feedback struct {
// SessionID identifies the owning session.
SessionID brand.SessionID `json:"sessionId"`
// MessageID identifies the message.
MessageID string `json:"messageId"`
// Rating is the score (-1, 0, or 1).
Rating Rating `json:"rating"`
// Note contains feedback text.
Note string `json:"note,omitempty"`
// Version is the CAS version, incremented on writes.
Version uint64 `json:"version"`
// CreatedAt is the creation time.
CreatedAt time.Time `json:"createdAt"`
// UpdatedAt is the last update time.
UpdatedAt time.Time `json:"updatedAt"`
}
Feedback records feedback on a message.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists message feedback.
func (*Store) Get ¶
func (s *Store) Get(ctx context.Context, session brand.SessionID, messageID string) (*Feedback, error)
Get reads feedback or returns NOT_FOUND.
func (*Store) Put ¶
func (s *Store) Put(ctx context.Context, session brand.SessionID, messageID string, rating Rating, note string, expectedVersion *uint64) (uint64, error)
Put creates or updates feedback and returns the new version. When supplied, expectedVersion is checked with CAS; a mismatch returns VERSION_CONFLICT.