-
-
Notifications
You must be signed in to change notification settings - Fork 280
Open
Labels
Description
There's two types of combined streams to support, each with a diff use case. The first one is easier than the second:
- static
- topics are known before the stream is opened
- these topics wont ever change for this stream after it is opened
- if disconnected, this can just respawn using the URL of the stream
- dynamic
- exact topics are unknown before the stream opens
- we need the ability to subscribe to new topics after the stream opens
- a partial implementation is here.
- I'm not sure how to determine the wskey. We could just dynamically generate one, and increment if the max limit is hit and a new one is made (see below). This is essentially just a primary key used to store state for a ws connection.
- we need the ability to unsubscribe from some topics after the stream opens.
- a partial implementation is here.
- Same problem as before, not sure yet how to determine the wskey used to store a list of topics for that connection (or how to find the correct wskey using the topic passed into
unsubscribe()
). Could just be a query in wsStore to find any/all wsKeys that have that topic.
- we will need to persist which topics are currently subscribed for this stream
- if the stream disconnects, we can reconnect and we know which topics to re-subscribe to.
- already partially implemented in
this.wsStore
, see the above partial implementation. - needs to be refactored similar to FTX connector, because topics are objects (not just strings).
- if easy to do, would be nice to keep it consistent with how the ftx connector does it (as it also tracks topics using objects used to sub to them).
Stretch goals for dynamic combined streams
- we may need to track how many topics are currently active on a stream (because there is a max limit of 200 per stream).
- if that cap is reached,
- we may need to see if we have other combined streams
- maybe using a wskey prefix (get all wskeys that start with `combined)
- or some dictionary to track this state
- if another combined stream is available AND max limit is not reached, request subscribe via that combined stream
- if not, spawn new combined stream (with new wskey) and send topic sub into the newly spawned stream.
- if that cap is reached,
mayrsascha, korniychuk and lavanphat