feedback

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var ErrEmptyNote = errors.New("feedback: note must contain a non-whitespace character")

ErrEmptyNote indicates a supplied note containing only whitespace.

View Source
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

func ValidateNote(note string) error

ValidateNote requires non-whitespace for nonempty notes; empty means omitted.

func ValidateRating

func ValidateRating(r Rating) error

ValidateRating accepts only ThumbsUp and ThumbsDown.

Types

type FailCode

type FailCode string

FailCode is a stable failure code.

const (
	CodeVersionConflict FailCode = "VERSION_CONFLICT"
	CodeSessionNotFound FailCode = "SESSION_NOT_FOUND"
	CodeNotFound        FailCode = "NOT_FOUND"
)

func CodeOf

func CodeOf(err error) FailCode

CodeOf extracts the stable failure code.

type FailError

type FailError struct {
	Code FailCode
	Msg  string
}

FailError carries a stable feedback failure code.

func (*FailError) Error

func (e *FailError) Error() string

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 Rating

type Rating int

Rating is a feedback score.

const (
	RatingThumbsDown Rating = -1
	RatingNone       Rating = 0
	RatingThumbsUp   Rating = 1
)

Rating values.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store persists message feedback.

func New

func New(backend storage.Backend) *Store

New creates a feedback store over an M45 storage backend.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, session brand.SessionID, messageID string) error

Delete removes a feedback record.

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) List

func (s *Store) List(ctx context.Context, session brand.SessionID) ([]Feedback, error)

List returns session feedback ordered by key.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL