feat: implement polling fallback for event communication #40
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
Server-side implementation of polling-based event notification fallback for Mesh v2. Adds
recordEventsByNodemutation andgetEventsSincequery to support environments where WebSocket connections are blocked.Implementation Details
GraphQL Schema Changes
New Types and Fields
RecordEventsPayload: Response type forrecordEventsByNodemutationnextSince: Cursor for nextgetEventsSincecallEvent.cursor: Sort Key (SK) for cursor-based paginationGroup.useWebSocket: Protocol selection flagGroup.pollingIntervalSeconds: Polling interval (when useWebSocket=false)Node.useWebSocket: Inherited from groupNode.pollingIntervalSeconds: Inherited from groupNew Mutations
createGroup: AddeduseWebSocketparameterrecordEventsByNode: Records events to DynamoDB (polling only)New Queries
getEventsSince: Retrieves events since last fetch (cursor-based)Server-side Timestamp Management
IMPORTANT:
recordEventsByNodeuses server-side timestamps, not client-sideevent.firedAt.Reason: 1+ second delay exists from device event firing to
recordEventsByNodecall.Implementation:
Benefits:
sinceparameter ingetEventsSinceCursor-based Pagination
getEventsSinceuses Sort Key (SK) as cursor:Environment Variables
MESH_EVENT_TTL_SECONDS: 10 (events auto-delete after 10 seconds)MESH_POLLING_INTERVAL_SECONDS: 2 (poll every 2 seconds)CDK Stack Changes
recordEventsByNodeandgetEventsSinceresolversuseWebSocketflagTesting
Unit Tests
recordEventsByNodesaves events with server-side timestampsgetEventsSinceretrieves events with cursor paginationcreateGroupacceptsuseWebSocketparameterIntegration Tests
Cost Optimization
Related
🤖 Generated with Claude Code