You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the Draft design of new WebSockets, a new WebSocketController should be implemented as part of the new WebSocket subscription system. The draft design document describes all requirements and relationships between components.
Structure description:
typeLimitsConfigurationstruct {
maxSubscriptionsuint64activeSubscriptions*atomic.Uint64maxResponsesPerSeconduint64sendMessageTimeout time.Duration
}
typeWebSocketBrokerstruct {
logger zerolog.Loggerconn*websocket.Conn// WebSocket connection for communication with the clientsubsmap[string]DataProvider// The key is the subscription ID limitsConfigurationLimitsConfiguration// Limits on the maximum number of subscriptions per connection, responses per second, and send message timeout.communicationChannelchaninterface{}
}
API Description
readMessages:
This method runs while the connection is active. It retrieves, validates, and processes client messages. Actions handled include subscribe, unsubscribe, and list_subscriptions. Additional actions can be added as needed.
writeMessages:
This method runs while the connection is active, listening on the broadcast channel. It retrieves responses and sends them to the client.
broadcastMessage:
This method is called by each DataProvider, receiving formatted subscription messages and writing them to the broadcast channel.
subscribe:
Triggered by the readMessages method when the action is subscribe. It extracts the topic from the message’s topic field, creates the appropriate DataProvider for the topic using the factory function CreateSubscription, and adds an instance of the new handler to the subs map. The client receives a notification confirming the successful subscription along with the specific ID.
unsubscribe:
It is triggered by the readMessages method when the action is unsubscribe. It removes the relevant handler from the subs map by calling DataProvider::Close and notifying the client of successful unsubscription.
listSubscriptions:
It is triggered by the readMessages method when the action is list_subscriptions. It gathers all active subscriptions for the current connection, formats the response, and sends it back to the client.
The text was updated successfully, but these errors were encountered:
Guitarheroua
changed the title
[Access] Implement new WebSocketBroker component to support multiple subscriptions per connection
[Access] Implement new WebSocketBroker component to support multiple subscriptions per connection
Oct 22, 2024
Guitarheroua
changed the title
[Access] Implement new WebSocketBroker component to support multiple subscriptions per connection
[Access] Implement new web socket controller component
Nov 12, 2024
WebSocketController Implementation
Based on the Draft design of new WebSockets, a new
WebSocketController
should be implemented as part of the new WebSocket subscription system. The draft design document describes all requirements and relationships between components.Structure description:
API Description
readMessages
:This method runs while the connection is active. It retrieves, validates, and processes client messages. Actions handled include
subscribe
,unsubscribe
, andlist_subscriptions
. Additional actions can be added as needed.writeMessages
:This method runs while the connection is active, listening on the
broadcast
channel. It retrieves responses and sends them to the client.broadcastMessage
:This method is called by each
DataProvider
, receiving formatted subscription messages and writing them to thebroadcast
channel.subscribe
:Triggered by the
readMessages
method when theaction
issubscribe
. It extracts the topic from the message’stopic
field, creates the appropriateDataProvider
for the topic using the factory functionCreateSubscription
, and adds an instance of the new handler to thesubs
map. The client receives a notification confirming the successful subscription along with the specific ID.unsubscribe
:It is triggered by the
readMessages
method when theaction
isunsubscribe
. It removes the relevant handler from thesubs
map by callingDataProvider::Close
and notifying the client of successful unsubscription.listSubscriptions
:It is triggered by the
readMessages
method when theaction
islist_subscriptions
. It gathers all active subscriptions for the current connection, formats the response, and sends it back to the client.The text was updated successfully, but these errors were encountered: