Conversation
Generated Code Check ✅All generated code is up to date. |
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.
Summary
Add GraphQL subscription support for real-time vehicle position streaming over WebSocket. Clients subscribe to
vehicle_positionsand receive live GTFS-RT vehicle position snapshots as they arrive, with optional filtering by bounding box and feed. The subscription path reads exclusively from the RT cache (no database), keeping the hot path fast.See
doc/design-vehicle-position-subscriptions.mdfor the full design document and remaining work items.GraphQL schema
Subscriptionroot type withvehicle_positions(where: VehiclePositionFilter)fieldVehiclePositionFiltersupportsbbox,feed_onestop_ids, andlimit(default/max 1000)VehiclePositiontype withtrip,feed_onestop_id,bearing,speedfieldsstop_idfromStop(DB-resolved object) toString(raw GTFS-RT value) to keep subscriptions DB-freeWebSocket infrastructure
wsAwareTimeoutmiddleware that bypasseshttp.TimeoutHandlerfor WebSocket upgrades while keeping the single router and full middleware stack (no middleware duplication)Hijack()onresponseWriterWrapperin meters middleware to support WebSocket upgradesRT cache pub/sub and vehicle position support
Subscribe()andGetSourceKeys()to theCacheinterfaceLocalCache: in-memory subscriber channels with non-blocking notificationRedisCache: Redis PSUBSCRIBE onrtfetch:sub:*channels; removed unused in-memory subscriber dead codeSource.processMessageGetVehiclePositions()andGetCachedFeedIDs()toRTFinderinterface and implementationSubscription resolver
convertVehiclePosition: maps protobuf VehiclePosition to GraphQL model (position, bearing, speed, vehicle, trip, stop info, timestamp)feed_onestop_ids(at feed level) andbbox(per position)limit(default 1000) to prevent unbounded responsesTesting
Dev tooling
cmd/rt-test-server: standalone binary generating synthetic vehicle positions with optional real RT feed fetchingtestdata/dmfr/rt-test.dmfr.jsonfixture for local testingTest plan
go test -run TestSubscription -v ./server/gql/...subscription { vehicle_positions { position bearing vehicle { id label } } }and verify WebSocket streamingwhere: { bbox: {...}, feed_onestop_ids: [...] }arguments