fix: preserve assignment event revisions

This commit is contained in:
Josh Creek
2026-09-01 08:13:35 +01:00
parent 23134796ee
commit 0cdb60c0d9
4 changed files with 27 additions and 2 deletions
+9 -1
View File
@@ -58,6 +58,10 @@ type AssignmentView struct {
ProtocolVersion int `json:"protocol_version"`
Transport string `json:"transport"`
JoinAuthorisation string `json:"join_authorisation"`
// Revision is routing metadata for the event stream, not part of the v1
// assignment response. Keeping it alongside the durable view prevents the
// REST recovery boundary from emitting a synthetic revision zero.
Revision uint64 `json:"-"`
}
type AssignmentProvider func(context.Context, string, string, time.Time) (AssignmentView, error)
@@ -509,10 +513,14 @@ func (s *Service) assignment(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusServiceUnavailable, "assignment_unavailable")
return
}
_ = s.PublishControlPlaneEvent(ControlPlaneEvent{Event: "assignment_changed", Revision: 0, ResourceID: view.MatchID, OccurredAt: now, MatchID: view.MatchID, ServerID: view.ServerID, PlayerID: view.PlayerID})
_ = s.PublishControlPlaneEvent(assignmentChangedEvent(view, now))
writeJSON(w, http.StatusOK, view)
}
func assignmentChangedEvent(view AssignmentView, now time.Time) ControlPlaneEvent {
return ControlPlaneEvent{Event: "assignment_changed", Revision: view.Revision, ResourceID: view.MatchID, OccurredAt: now, MatchID: view.MatchID, ServerID: view.ServerID, PlayerID: view.PlayerID}
}
type rankedProfileResponse struct {
Rating float64 `json:"rating"`
RD float64 `json:"rd"`