Standard WebSocketTask Per Service
Jump to navigation
Jump to search
Overview
If client begins a task on the backend and awaits that tasks completion we open a websocket connection so client can be notified when task is complete.
DynamoDB structure
WebSocketTask
- all websocket tasks for one service can record the awaiting connection in a single table
- all connections awaiting a specific task to complete will share the same partition key
- sortKey is a list of all websocket connectionIds waiting this specific task, so can query by partition key to get all awaiting connections
Fields
- taskKey
- (partition key)
- {taskTag}_{taskId}
- taskTag: string that describes the task, eg: "processSortRequest"
- taskId: uniqueId of the task being performed, eg: sortResultId
- connectionid
- (sort key)
HdrWbs handlers
- request from the client to initiate the task uses a websocket (Wbs) handler to invoke the core function
- HdrWbs receives websocket routes connect, disconnect, and message
- connect: starts the connection, no logic required
- message: receives the request params to start the task, saves record into WebSocketTask table
- disconnect: client has the option of sending a disconnect message, this will remove the connection record from WebSocketTask table, so no need to process once complete