feat: validate queue compatibility metadata

This commit is contained in:
Josh Creek
2026-08-31 21:57:40 +01:00
parent 0551fb0b1f
commit b2ee9ec92d
6 changed files with 126 additions and 18 deletions
+17 -5
View File
@@ -15,14 +15,26 @@ const (
RatingWidenPeriod = 30.0
)
// QueueSpec is the compatibility contract selected by the authenticated
// client. CandidateProviderV2 may use it to resolve a server-owned projection
// from the verified account and current deployment configuration.
type QueueSpec struct {
Playlist Playlist
ClientBuild string
ProtocolVersion int
}
// Candidate is the server-side projection of a verified, live queue ticket.
// RTT values come from backend probes, never from the client request body.
type Candidate struct {
TicketID string
PlayerID string
Rating float64
EnqueuedAt time.Time
PredictedRTT map[string]float64
TicketID string
PlayerID string
Playlist Playlist
ClientBuild string
ProtocolVersion int
Rating float64
EnqueuedAt time.Time
PredictedRTT map[string]float64
}
type Selection struct {
+2 -1
View File
@@ -26,6 +26,7 @@ type QueueTicket struct {
TicketID string
PlayerID string
Candidate Candidate
Playlist Playlist
State State
Revision uint64
EnqueuedAt time.Time
@@ -70,7 +71,7 @@ func (q *Queue) Create(playerID, ticketID, idempotencyKey string, candidate Cand
if _, ok := q.tickets[ticketID]; ok {
return QueueTicket{}, fmt.Errorf("%w: ticket ID already exists", ErrConflict)
}
ticket := QueueTicket{TicketID: ticketID, PlayerID: playerID, Candidate: candidate, State: Queued, EnqueuedAt: now, ExpiresAt: now.Add(QueueExpiryWindow)}
ticket := QueueTicket{TicketID: ticketID, PlayerID: playerID, Candidate: candidate, Playlist: candidate.Playlist, State: Queued, EnqueuedAt: now, ExpiresAt: now.Add(QueueExpiryWindow)}
q.tickets[ticketID] = ticket
q.byPlayer[playerID] = ticketID
q.mutations[idempotencyKey] = queueMutation{digest: digest, ticket: ticket}