Confirmation when unsubscribed from a channel #260
Replies: 1 comment
-
Great topic, thanks for submitting this discussion!
There is a large gap in the library surrounding subscribe/unsubscribe, on the subscribe side I see this manifesting a myriad of issues, to name a few:
The unsubscribe use case you suggested is pretty interesting and I think we can resolve that. As you mentioned, unsubscribe is treated as a synchronous operation from the client's perspective. To make it async, the client needs to be aware of whether it supports unsubscribe confirmations. Resolving this add some additional complexity as we introduce some intermediary state. Right now it's only Perhaps a bigger issue is that many exchanges don't provide a confirmation message for sub/unsub. For these we should just avoid this complexity and make the clients treat sub/unsub as synchronous processes.
Indeed! I guess the best place to start is where I want things to end up eventually, then we can figure out a solution to get there. The architecture I want to get to is treating subscriptions as state machines. As a type they would contain the subscription details: market, type, arguments. Subscription will be scheduled by the client and assigned to a transport. Once the transport is available, the subscription payload is sent along the transport and is If the socket disconnects, the subscription becomes With unsubscribe, we could just transition to an |
Beta Was this translation helpful? Give feedback.
-
The problem
Explanation
Currently once sending an unsubscribe message you're not informed if/when it unsubscribed successfully, and your subscription is immediately removed from the map of subscriptions, i.e.
_level2UpdateSubs
. It would be helpful to add some type of indicator that an unsubscribe was successful for a channel if the exchange supports it, and to be able to keep receiving messages until the unsubscribe is successful.Particularly it would help when validating order books and the sequenceId is shared across channels since you need to know when you can stop listening for events for a channel.
This could be done a few different ways so I've started a discussion here first before creating an issue. I imagine this would probably involve either changing an existing API or adding a new one.
Beta Was this translation helpful? Give feedback.
All reactions