Repository navigation
[Backend][Frontend] websocket & payload: relay-only broker, TopicPayload and backend/message - #687
Merged
Merged
Conversation
JavierRibaldelRio
marked this pull request as ready for review
December 4, 2026 01:04
Sagah123
reviewed
Dec 4, 2026
pminmic
reviewed
Dec 4, 2026
pminmic
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
THIS PR MODIFIES THE FRONTEND, NOT ONLY THE BACKEND.
Frontend packages changed:
frontend-kit,testing-view,competition-viewandlogging-view.It changes the WebSocket contract (heartbeat, telemetry and message payloads), so it needs a review from someone working on the frontend as well.
Frontend changes (this PR modifies the frontend)
frontend-kit): the kit sendsconnection/heartbeatas soon as the socket opens and then every 25 ms (it was every 1000 ms). The backend now gives up on the frontends after 100 ms without a message from any of them.Files:
kit/src/core/websocket.ts,kit/src/core/types.ts(SocketConfig.heartbeatIntervalMsdocs).hexValueremoved from the telemetry types:kit/src/core/types.ts(TelemetryPacket)logging-view/src/types/telemetry.tstesting-view/src/types/data/telemetryCatalogItem.ts(RawPacket)testing-view/src/mocks/telemetry.tscompetition-view/scripts/mock-backend.mjscounterremoved fromMessageTimestamp:testing-view/src/types/data/message.tsand itsformatTimestamptestcompetition-view/src/types/message.tscompetition-view/scripts/mock-backend.mjsNot migrated yet (follow-up PRs):
measurementUpdateskeys are now numeric measurement ids. The apps still look values up by the Go catalog key (e.g.testing-viewTelemetryValue.tsx)./backend/podDataStructureand/backend/orderStructures.originfield ofmessage/updateor the newbackend/messagetopic yet.Wire changes the frontend sees
connection/heartbeatpodData/updatehexValue;measurementUpdateskeyed by numeric measurement idmessage/updatekindisinfo,warning,faultorpanic(nook); neworiginfield; nocounterintimestampprotection/updatetimestampuses the calendar format ofmessage/update:{second, minute, hour, day, month, year}order/stateOrdersbackend/messageBackend:
websocketwatch; event topics usebroadcast(128 events each).runreturnsFrontendDisconnectedafterDEFAULT_HEARTBEAT_TIMEOUT(100 ms) without a valid message from any frontend, and traces it witherror!.Subscriberdoes not keep the broker alive.info!when a frontend connects, when a session ends (with the active count) and when the broker stops.TopicPayload::TOPIC). The sender writes each frame withto_message().backend/message:publish_backend_messageandsubscribe_backend_messages.Backend:
payloadTopicPayloadtrait: aconst TOPICand a defaultto_message()that serializes{topic, payload}in one pass. Every backend → frontend payload implements it.ConnectionUpdate,DataUpdateandLoggerResponseare now newtypes; their JSON is unchanged.MessageKindreplaced by core'sMessageLevel.protection_level(Severity)gives the level a protection is shown with.message/updategainsorigin: where on the board the message was produced, taken fromMessagePacket.origin. It is empty for messages the backend produces itself.protection/update:ProtectionUpdate::new(packet, timestamp)with aMessageTimestamp.order/stateOrders,hexValueandcounter.BackendMessage(backend/message):kind(MessageLevel),board(nullwhen not known),textandtimestamp. It carries theProblems fromevent.to_message()against every example file.Pending
FrontendDisconnectedtoeventas a fatalProblemoncebackend/eventis merged (TODOs inwebsocket::runandmain.rs).BackendMessagefrom eachProblem(ProblemKind→MessageLevel, date fromat, board name from the ADJ).originandbackend/message.clippy -D warningsreports 5 errors that predate this PR (websocket/order.rs,http/server.rs).cargo fmtof untouched files is deferred.Testing
cargo test -p station: 47 passed.testing-viewandcompetition-view:tscclean; vitest: 116 passed.competition-viewrun against its mock backend: messages showHH:MM:SSwithoutcounter, and telemetry arrives withouthexValue.testing-viewrun in its own mock mode: loads with no page errors.